参考资料纯粹取自以下网站:-
http://syntx.io/integrating-your-java-spring-mvc-webapp-with-facebook-doing-the-oauth-dance/ 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 http://www.oodlestechnologies.com/blogs/OAuth-2.0-implementation-in-Spring-Framework
我已经开发了 String Security OAuth2 Facebook 集成示例,现在我期待开发安全 OAuth2 谷歌(以及后来的 Github)集成示例,其中将提供 AppID 和 Secret 以获取“access_token”和“refresh_token”等,以用于访问受保护的资源(如 UserDetails 等)。
所以,第一步将是注册应用程序http://code.google.com/apis/console http://code.google.com/apis/console。所以它给了我“客户端ID”和“客户端秘密”,我还配置了重定向URI,完成!
现在我已经开始编写实际的 Apache OAuth 客户端,但我不确定需要提供哪些参数(类似地,我为 Facebook 集成提供了这些参数,这些参数在 facebook 上很容易获得,同时进行 google 搜索,但在 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();