【问题标题】:Spring boot Oauth 2 configuration cause to 401 even with the permitall antMatchers即使使用 permitall antMatchers,Spring boot Oauth 2 配置也会导致 401
【发布时间】:2017-08-09 21:13:39
【问题描述】:

我是新的 Spring Boot 和 Aouth 2。我尝试使用 OAuth2 保护我的 Spring Boot 应用程序。但是我的身份验证无法正常工作,即使使用不安全的网址也会导致 401 错误。我的代码可以在 git hub 的 url 下找到

我使用了下面的 curl 命令

curl -i http://localhost:8990/api/hello

但结果是

{"timestamp":1489824873836,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource","path":"/api/hello"}

此外,当我尝试如下访问我的安全网址时,它会产生相同的错误。

curl -i -H "Authorization: Bearer <access_token>" http://localhost:8990/api/secure

我在互联网上进行了搜索,但仍无法解决我的问题。谁能帮帮我

谢谢

Git 中心网址

https://github.com/txmr765/Spring-Oauth2

【问题讨论】:

  • 链接断开,Answer 和 Response 都不完整。

标签: spring-boot spring-security oauth-2.0 spring-oauth2


【解决方案1】:

身份验证代码几乎没有什么需要更改的,现在它正在工作。

只需检查 curl -vu secureapp:secret 'http://localhost:8990/api/oauth/token?username=admin&password=admin&grant_type=password'

【讨论】:

    猜你喜欢
    • 2019-03-25
    • 2021-10-25
    • 2015-10-13
    • 2018-01-31
    • 1970-01-01
    • 2019-09-27
    • 1970-01-01
    • 2021-05-25
    • 2021-04-23
    相关资源
    最近更新 更多