Oauth2 Spring 安全授权码
Oauth2 Spring Security Authorization Code
我正在尝试重现此处提供的 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 或密码
使用authorization_code:
打开浏览器并访问授权端点
http://localhost:9999/uaa/oauth/authorize?response_type=code&client_id=acme&redirect_uri=http://example.com
登录过程完成后(登录名:用户密码:密码),您将被重定向到
http://example.com/?code=CODE <-- 这是您应该在下一个请求中使用的代码
现在你得到了令牌:
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 服务器:
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 或密码
使用authorization_code:
打开浏览器并访问授权端点 http://localhost:9999/uaa/oauth/authorize?response_type=code&client_id=acme&redirect_uri=http://example.com
登录过程完成后(登录名:用户密码:密码),您将被重定向到 http://example.com/?code=CODE <-- 这是您应该在下一个请求中使用的代码
现在你得到了令牌:
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