Spring Boot:访问此资源需要完全身份验证

新手上路,请多包涵

我正在从这篇文章 https://github.com/angel-git/wso2is-springoauth 中使用 wso2is 服务器做 Spring Boot Security 的示例,当我尝试使用访问令牌访问资源时,我得到了

{“error”:“unauthorized”,“error_description”:“访问此资源需要完全身份验证”}

我通过以下方式生成访问令牌:

curl -u CLIENT_ID:CLIENT_SECRET-k -d “grant_type=password&username=admin&password=admin” -H “Content-Type:application/x-www-form-urlencoded” https://localhost:9443/oauth2/token

并通过以下方式访问资源:

curl -H GET “授权:ACCESS_TOKEN” http://localhost:8080/greeting

我在 stackoverflow 上找到了很多解决方案,但不幸的是无法解决我的问题

请帮忙,谢谢

原文由 deen 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.5k
2 个回答

非常感谢帮助我解决问题的 Angel Gavalda。我使用以下命令生成访问令牌和访问资源

对于生成访问令牌:-

curl -k -d ‘grant_type=client_credentials&client_id=yourClientId&client_secret=yourClientSecret’ https://localhost:9443/oauth2/token

访问资源:-

curl -k -H “授权:承载 $ACCESS_TOKEN” http://localhost:8080/greeting

原文由 deen 发布,翻译遵循 CC BY-SA 3.0 许可协议

我收到了相同的错误消息

"curl http://localhost:8080/spring4/beans" :
{"timestamp":1493591079040,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource.","path":"/spring4/beans"}

application.properties 中设置以下属性绕过了安全检查,我可以使用所有的 acuator 端点:

 management.security.enabled=false

原文由 user3448327 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进