我使用社交网络 Vkontakte 作为 Oauth2 授权服务器。所以我有几个步骤:
1)通过请求获取代码请求类型=代码2)当我发送请求访问令牌uri时获取accessToken
所以我想使用 Spring Oauth2,但我应该首先获取授权代码,然后获取访问令牌,我尝试添加到 application.yml :
authorized-grant-types: authorization_code
这是我的 application.yml:
security:
oauth2:
client:
clientId: [clientId]
clientSecret: [clientSecret]
accessTokenUri: https://oauth.vk.com/access_token
userAuthorizationUri: https://oauth.vk.com/authorize
tokenName: access_token
registered-redirect-uri: http://localhost:8080/login
resource:
token-info-uri: http://localhost:8080/user
但实际上这没有帮助。如果有人遇到过这个问题并且知道如何配置 Spring Oauth2 应用程序 - 将不胜感激
实际上,经过几天的调查,我发现 Spring OAuth2 完全实现了我的客户端应用程序的所有功能和配置,使用授权码授予 https://www.rfc-editor.org/rfc/rfc6749#section-4从 Vkontakte(授权服务器)获取访问令牌
如果我作为样本,我唯一需要做的就是Spring Boot 和 OAuth2 社交登录简单 https://spring.io/guides/tutorials/spring-boot-oauth2/#_social_login_simple是要填充应用程序.yml具有我的授权服务器的正确信用:
security:
oauth2:
client:
clientId: xxxxxxx
clientSecret: xxxxxxxxxxx
accessTokenUri: https://oauth.vk.com/access_token
userAuthorizationUri: https://oauth.vk.com/authorize
tokenName: code
authenticationScheme: query
clientAuthenticationScheme: form
grant-type: authorization_code
resource:
userInfoUri: https://api.vk.com/method/users.get
我面临的唯一问题是提供正确的代币名称 and 用户信息Uri检索记录的用户信息。
根据代币名称这是您通过授权后获得的授权码名称(response_type=代币名称,它调用code在我的例子中)并用于获取访问令牌。
希望对遇到同样问题的人有所帮助
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)