5
votes

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?

1
user.phonenumbers.read should return the phone numbers with container type PROFILE without needing the contacts scope. Some things to check: 1) How are you making the request? Is it a get request for the person resource name? 2) Are you sure the phone numbers that show up after adding contacts scope are of container type PROFILE?Amos Yuen
@AmosYuen You are right. It returned with container type PROFILE without needing the contacts scope BUT only after adding the contact details in the 'Google Plus Profile'. Earlier it was returning with CONTACT container which was actually my own phone number which I had saved as a contact. Thank you you the help!Vismay Patel

1 Answers

7
votes

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.