Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't read phone numbers from user's google profile using - auth/user.phonenumbers.read scope

Based on the documentation of Google People API I am using profile scope - https://www.googleapis.com/auth/user.phonenumbers.read and PersonFields=phoneNumbers to read the authenticated user's phone numbers only in their Google profile (none from the contact list). I am using API key and oAuth accesstoken to authorise the request. The google people API is not fetching the phone numbers associated with the profile with the above scope alone. Adding the scope for the entire contact list read access in addition to the above scope, which is www.googleapis.com/auth/contacts.readonly returns the phone numbers from the profile correctly. Is there any way to get user's phone numbers from his/her profile using only the user.phonenumbers.read scope?

like image 413
Vismay Patel Avatar asked Oct 10 '17 08:10

Vismay Patel


People also ask

How do I read the contacts of an authenticated user?

To read the authenticated user's contacts, request one of the following scopes: Requests that your app be given read and write access to the authenticated user’s Google Contacts . Requests that your app be given read access to the authenticated user’s Google Contacts .

How do I get the profile information of a Google user?

Getting Profile Information. After you have signed in a user with Google, if you configured Google Sign-In, with the DEFAULT_SIGN_IN parameter or the requestProfile method, you can access the user's basic profile information. If you configured Google Sign-In with the requestEmail method, you can also get their email address.

Why can't I open a Google account without a phone number?

"This phone number cannot be used for verification" explains why a number is needed to verify your account via sms or a voice call. If Google require a number, and you cannot provide one, or you cannot open an account using the methods described above, then Google will not let you open the account.

What happens when you request data from Google?

If the user approves, then Google gives your application a short-lived access token. Your application requests user data, attaching the access token to the request. If Google determines that your request and the token are valid, it returns the requested data.


1 Answers

I could figure out the problem. For 'user.phonenumbers.read' scope the documentation of people API states - 'your app be given read access to the authenticated user's phone numbers in their Google profile'.

But by 'Google profile' it indicates the Google Plus Profile which is completely different form their core google profile - My Account. People API is fetching information only from the Google Plus Profile.

So even if a user has his/her contact details added in My Account, the People API will not fetch their phone numbers unless they have added them manually in their Google Plus Profile. After adding the contact details I could fetch contact details with 'auth/user.phonenumbers.read' without the need of adding 'auth/contacts.readonly' scope.

like image 76
Vismay Patel Avatar answered Oct 01 '22 03:10

Vismay Patel