3

Our system using Google Oauth to allow a user to sign up from Google account. However, for some of the users, we can only get email and avatar but not First Name and Last Name.

The setting in Oauth Google Console having following scopes added

  • email
  • profile
  • openid
  • /auth/contacts.readonly

Using the following scope for requesting

The result return from API is

{
  "identifier": "1026834XXX",
  "webSiteURL": "",
  "profileURL": "",
  "photoURL": "https:\/\/lh3.googleusercontent.com\/a-\/AAuE7mAZnGB1XXX",
  "displayName": "",
  "description": "",
  "firstName": "",
  "lastName": "",
  "gender": "",
  "language": "",
  "age": "",
  "birthDay": 0,
  "birthMonth": 0,
  "birthYear": 0,
  "email": "[email protected]",
  "emailVerified": "",
  "phone": "",
  "address": null,
  "country": "",
  "region": "",
  "city": null,
  "zip": ""
}

Isn't every gmail account should have firstName and lastName ?

5
  • If the user hasnt filled out the information google cant return it to you. Commented Oct 10, 2019 at 7:38
  • Thanks for your reply. Isn't the first name and last name is mandatory when creating Gmail account? Commented Oct 10, 2019 at 21:39
  • nope not as far as i know Commented Oct 11, 2019 at 10:22
  • @DaImTo Thanks for your comment, do you know the way to create a Gmail account without first name and last name? Commented Nov 11, 2019 at 23:09
  • I cant tell you that I haven't created a google account in a number of years you might want to try theses could also be legacy accounts created before they started requiring first name and last name to create an account . It could also be an account merged from another email provider. you may want to try webmasters.stackexchange.com Commented Nov 12, 2019 at 7:22

1 Answer 1

1

Google only returns the data it has about a user so if the user hasnt filled the information out then the api isnt going to return it. Also some of this information can be set to private by the user namely birth date, in order for the api to return that data the user must have set their birth date to public in their profile.

The only advice i can give is to add fields=* to your request this should ensure that all of the data that google has is returned. Some of the Google APIs limit the response and require you to use the fields parameter on the call if you want additional data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.