Kevin Simple
Kevin Simple

Reputation: 1213

Google OAuth returns empty Family/Given name

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 ?

 var loginInfo = new ExternalLoginInfo();
 loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

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

Many thanks!

Upvotes: 2

Views: 2445

Answers (1)

Kevin Simple
Kevin Simple

Reputation: 1213

so happy I got the solution now, the solution is to add the specific scope(https://www.googleapis.com/auth/plus.login) in the request to google oauth, then if the user's google account hasn't got google plus enabled, it will prompt user to create google plus profile first then accept you app to access the user's google account/plus information.

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

Upvotes: 3

Related Questions