我正在使用spring-social-google (由git构建)来允许人们登录我的Spring应用程序(我已经有了facebook、twitter和linedin工作)。下面的表单允许我进行身份验证,但不返回电子邮件地址,禁止向Google+时间线发送邮件:
<form action="<c:url value="/register/social/${providerId}" />" method="POST" id ="${providerId}Form" name = "${providerId}Form">
<button type="submit"><img src="<c:url value='/resources/${providerId}/sign-in-with-${providerId}.png'/>" border="0"/></button>
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/plus.profile.emails.read" />
</form>我认为问题在于我没有正确的范围变量。我在这里尝试过一些组合,https://developers.google.com/+/api/oauth,但是我被告知范围变量都是错误的。我需要哪一个?
这是我用来获取电子邮件地址的代码:
public final class LoginConnectionSignUp implements ConnectionSignUp
{
public String execute(Connection<?> connection)
{
final UserProfile up = connection.fetchUserProfile();
final String email = up.getEmail();
// ...
}
}发布于 2014-05-20 18:54:03
这里有几个问题:
目前谷歌的API不支持在Google+流上发布信息。该软件包似乎允许您创建“应用程序活动矩”,这些内容存储在用户的配置文件中.但这些不是流向溪流的帖子。为了生成一个应用程序活动,您需要包含https://www.googleapis.com/auth/plus.login作用域。
此外,还可以包括email作用域或https://www.googleapis.com/auth/plus.profile.emails.read作用域。使用这些作用域,您应该能够将电子邮件地址作为调用的一部分
Person person = google.plusOperations().getPerson("me");因此,您的输入标记可能应该类似于
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read" /> (注意要使用的两个作用域之间的空格)。
重要注意事项:文档讨论如何通过电话获得电子邮件,如
GoogleUserInfo userInfo = google.userOperations().getUserInfo();虽然这可能暂时有效,但已被取消,计划在9月份取消。在这个时候,userinfo作用域也被设置为弃用。不要使用此方法或这些作用域。(并与提交人联系,告诉他们不要这样做。)
https://stackoverflow.com/questions/23766630
复制相似问题