弹簧启动 Oauth 2 配置导致 401 即使与允许所有蚂蚁匹配器



我是小新春靴和Aouth 2。我试图用OAuth2保护我的弹簧启动应用程序。但是我的身份验证是有效的,即使使用不安全的 url,它也会导致 401 错误。我的代码可以在 git 集线器中找到

,网址下

我使用了下面的 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"}

同样,当我尝试访问我的安全 url 时,如下所示,它会产生相同的错误。

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

我已经在互联网上搜索过,但还无法解决我的问题。有人可以帮我吗

谢谢

Git 中心网址

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

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

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

最新更新