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

1

6

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?

Bottom answered 10/10, 2017 at 8:19 Comment(3)
refer this : https://mcmap.net/q/1019901/-retrieving-a-user-39-s-phone-number-from-gsuite-oauthCinerarium
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?Lashonda
@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!Bottom
B
9

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.

Bottom answered 23/10, 2017 at 7:38 Comment(1)
How to fetch client phone numbers in php?Vivavivace

© 2022 - 2024 — McMap. All rights reserved.