Spring-Security-Oauth2:访问此资源需要完全身份验证

新手上路,请多包涵

我正在尝试将 spring-security-oauth2.0 与基于 Java 的配置一起使用。我的配置已完成,但是当我在 tomcat 上部署应用程序并点击 /oauth/token 访问令牌的 url, Oauth 生成以下错误:

 <oauth>
<error_description>Full authentication is required to access this resource</error_description>
<error>unauthorized</error>
</oauth>

我的配置在 Git hub 上,请点击链接

代码量大,参考git。我正在使用 chrome postman 客户端发送请求。以下是我的要求。

 POST /dummy-project-web/oauth/token HTTP/1.1
Host: localhost:8081
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id=abc%40gmail.com&client_secret=12345678

错误就像,URL 是安全的 Oauth ,但在配置中,我授予访问此 URL 的所有权限。这个问题到底是什么?

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

阅读 617
1 个回答

client_idclient_secret ,默认情况下,应该放在授权标头中,而不是 form-urlencoded 主体中。

  1. 连接你的 client_idclient_secret ,它们之间有一个冒号: abc@gmail.com:12345678
  2. Base 64编码结果: YWJjQGdtYWlsLmNvbToxMjM0NTY3OA==
  3. 设置授权标头: Authorization: Basic YWJjQGdtYWlsLmNvbToxMjM0NTY3OA==

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

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