gpt4 book ai didi

oauth-2.0 - Oauth2 Spring 安全授权码

转载 作者:行者123 更新时间:2023-12-05 01:33:05 26 4
gpt4 key购买 nike

我正在尝试重现此处提供的 oauth 服务器:

https://spring.io/blog/2015/02/03/sso-with-oauth2-angular-js-and-spring-security-part-v
测试这个基本服务器的 curl 调用应该是:

curl acme:acmesecret@localhost:9999/uaa/oauth/token  \
-d grant_type=authorization_code -d client_id=acme \
-d redirect_uri=http://example.com -d code=jYWioI

虽然我不断收到以下错误:
无效授权码:jYWioI

这个授权码在授权服务器哪里配置?

最佳答案

您需要生成一个新的授权码!

您可以使用授权类型 authorization_code 或密码来做到这一点

使用授权码:

打开浏览器并访问授权端点
http://localhost:9999/uaa/oauth/authorize?response_type=code&client_id=acme&redirect_uri=http://example.com

登录过程(登录:用户密码:密码)后,您将被重定向到
http://example.com/?code=CODE <-- 这是您应该在下一个请求中使用的代码

现在你得到了 token :

curl acme:acmesecret@localhost:9999/uaa/oauth/token -d grant_type=authorization_code -d client_id=acme -d redirect_uri=http://example.com -d code=CODE

响应:{"access_token":"eyJhbGciOiJS ....."}

使用密码 grantType:
curl acme:acmesecret@localhost:9999/uaa/oauth/token  -d grant_type=password -d username=user -d password=password

响应:{"access_token":"eyJhbGciOiJS ....."}

我建议您阅读有关 oauth grantTypes 的更多信息,以了解什么更适合您的解决方案
https://aaronparecki.com/articles/2012/07/29/1/oauth2-simplified

关于oauth-2.0 - Oauth2 Spring 安全授权码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33377971/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com