Spring引导Oauth 2配置导致401即使使用permitall antMatchers也是如此

时间:2017-03-18 08:54:27

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

我是一个新的Spring引导和Aouth 2.我尝试使用OAuth2保护我的spring启动应用程序。但是我的身份验证工作正常,即使使用不安全的URL也会导致401错误。我的代码可以在git hub中找到under 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 hub url

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

1 个答案:

答案 0 :(得分:2)

验证码几乎没有什么可以改变的,现在它正在发挥作用。

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

相关问题