Google OAuth returns empty Family/Given name

时间:2015-07-29 00:42:47

标签: google-oauth

I am working on Google OAuth for user to sign up(asp mvc application), I want to retrieve the user's family name and given name once they authorized the permission for my app, But if the user hasn't enable/join Google Plus, the call back api return me empty family name and given name, if use have Google Plus enabled, then I can get their family/given names, So, Here is my question, is it possible getting google user's family/given name through OAuth without user have to enable Google Plus ?

ReactRouter.run(routes, hashlocation, (Handler) => {
  React.render(<Handler/>);
});

LoginInfo have family/given name properties but they are empty string.

Many thanks!

1 个答案:

答案 0 :(得分:3)

很高兴我现在得到了解决方案,解决方案是在google oauth的请求中添加特定范围(https://www.googleapis.com/auth/plus.login),然后如果用户的Google帐户没有启用google plus,则会提示用户首先创建谷歌加配置文件然后接受您的应用程序访问用户的谷歌帐户/加信息。

google oauth ref:https://developers.google.com/+/web/api/rest/oauth