【发布时间】:2015-06-10 06:00:13
【问题描述】:
参考资料纯粹取自以下网站:-
http://syntx.io/integrating-your-java-spring-mvc-webapp-with-facebook-doing-the-oauth-dance/
http://www.oodlestechnologies.com/blogs/OAuth-2.0-implementation-in-Spring-Framework
我已经开发了 String Security OAuth2 Facebook 集成示例,现在我期待开发 Security OAuth2 Google(以及后来的 Github)集成示例,其中将提供 AppID 和 Secret 以获得“ access_token" 和 "refresh_token" 等用于访问受保护的资源,如 UserDetails 等。
所以,第一步是在http://code.google.com/apis/console 上注册应用程序。所以它给了我“客户端 ID”和“客户端密码”,我还配置了重定向 URI,完成!
现在我已经开始编写实际的 Apache OAuth 客户端,但我不确定我需要提供哪些参数(类似于我为 Facebook 集成提供的参数,这些参数在 facebook 上很容易获得,同时进行谷歌搜索,但没有找到对于 Google),请给我建议应该为以下空白参数提供哪些值 -
我想我已经提供了足够的信息,所以任何指导/帮助/链接都非常感谢。
OAuthClientRequest request = OAuthClientRequest
.authorizationLocation("")
.setClientId("3kT21Hlkzzt5eV1")
.setRedirectURI("http://localhost:8080/apache-oltu/google/redirect")
.setResponseType("")
.setScope("")
.buildQueryMessage();
以下代码是为回调开发的
private void getAccessToken(String authorizationCode) throws OAuthSystemException, OAuthProblemException {
OAuthClientRequest request = OAuthClientRequest
.tokenLocation("")
.setGrantType()
.setClientId("3kT21H5EO3zzt5eV1")
.setClientSecret("1kT21Hdlkzzt5eV1")
.setRedirectURI("http://localhost:8080/apache-oltu/google/redirect")
.setCode()
.buildBodyMessage();
添加以下代码以获取受保护的资源,例如用户配置文件:
request= new OAuthBearerClientRequest("https://www.googleapis.com/auth/userinfo.profile").
setAccessToken(oAuthResponse.getAccessToken()).
buildQueryMessage();
【问题讨论】:
标签: spring-security oauth-2.0 google-oauth oltu