GoogleConntectionFactory无法创建连接
G'day everyone!GoogleConntectionFactory无法创建连接
我有错误是这样的:
WARN/DefaultRequestDirector(22739): Authentication error: Unable to respond to any of
these challenges: {authsub=WWW-Authenticate: AuthSub
realm="https://www.google.com/accounts/AuthSubRequest" allowed-
scopes="https://www.googleapis.com/auth/userinfo.email,
https://www.googleapis.com/auth/userinfo.profile,
https://www.googleapis.com/auth/userinfo.id"}
这是happend当我想要得到的连接:
AccessGrant accessGrant = new AccessGrant(accessToken);
Connection<Google> connection = connectionFactory.createConnection(accessGrant);
其结果是,我赶上例外,因为验证401
没任何一个这个问题都要归功于?
我发现它为什么发生了。问题在于范围。我只设置了https://www.googleapis.com/auth/plus.me范围。创建连接是不够的。
至于结果,我有一个消息:
WARN/DefaultRequestDirector(22739): Authentication error: Unable to respond to any of
these challenges: {authsub=WWW-Authenticate: AuthSub
realm="https://www.google.com/accounts/AuthSubRequest" allowed-
scopes="https://www.googleapis.com/auth/userinfo.email,
https://www.googleapis.com/auth/userinfo.profile,
https://www.googleapis.com/auth/userinfo.id"}
正如你可以看到谷歌的oauth2询问https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/userinfo.profile,https://www.googleapis.com/auth/userinfo.id范围。
我添加了这个范围后,我得到了一个新的错误,如“invalid_scope”。
问题出在连接网址。
我创建的连接网址为:
connectionFactory.getOAuthOperations().buildAuthorizeUrl(GrantType.AUTHORIZATION_CODE, params);
其中PARAMS:
OAuth2Parameters params = new OAuth2Parameters();
params.setRedirectUri(redirectUri);
params.setScope("https://www.googleapis.com/auth/userinfo.email+" + "https://www.googleapis.com/auth/userinfo.profile+" + "https://www.googleapis.com/auth/userinfo.id+" +
"https://www.googleapis.com/auth/plus.me");
在这种情况下,符号 “+” 被解码为一个又一个和谷歌的oauth2 API无法识别范围集。
我希望这个解决方案将来会有所帮助。
当您应该使用OAuth2身份验证时,您看起来像使用旧的AuthSub身份验证。我建议你看看example application,具体见SocialConfig如何创建用于登录的ProviderSignInController。
我用的OAuth2,但我不能创建连接
日志包括你美国企图利用的AuthSub。我再次建议您复制示例应用程序以开始使用。 – Gabriel 2012-07-30 14:00:35
不幸的是,我不使用社交春天在Android应用程序 – Rusfearuth 2012-08-21 08:53:19
我想这是因为DefaultRequestDirector的happend在要求范围上的钥匙不能回应... – Rusfearuth 2012-07-30 02:29:41