我正在尝试复制此处提供的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:
登录过程(登录:用户密码:password)之后,您将被重定向到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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句