Google People API未返回全部电话号码来源,能否获取账号关联号码?
people/me? Absolutely, the Google People API can retrieve the phone number associated with a user's core Google account (not just the one in their Google+ profile), but there are a few critical details you need to get right to make this work:
1. Use the correct OAuth scope
The profile scope only grants access to public profile data (like Google+ phone numbers set to public). To access the phone number linked directly to the user's Google account, you must request the https://www.googleapis.com/auth/user.phonenumbers.read scope. Make sure your web app explicitly asks for this scope during authentication—without it, the API won't return account-level phone numbers.
2. Specify the required personFields parameter
By default, the people.get endpoint doesn't return all available fields. You need to explicitly tell the API which fields you want to retrieve. For phone numbers, include phoneNumbers in the personFields parameter.
For example, a valid API request would look like this:
GET https://people.googleapis.com/v1/people/me?personFields=phoneNumbers
If you're using a client library (like Python), your code would resemble:
from googleapiclient.discovery import build service = build('people', 'v1', credentials=your_credentials) response = service.people().get( resourceName='people/me', personFields='phoneNumbers' ).execute()
3. Verify the user's account has a linked phone number
The API can only return data that exists in the user's account. Have the user check their Google account settings: go to Personal info > Contact info to confirm they've added a phone number directly to their account (not just their Google+ profile).
4. Check data sources in the response
When you get the response, each phone number entry will have a metadata.source.type field. Account-linked numbers will show ACCOUNT as the type, while Google+ profile numbers will show PROFILE. This helps you distinguish where each number comes from.
Note about API Explorer testing
When testing in API Explorer, double-check that you've selected the https://www.googleapis.com/auth/user.phonenumbers.read scope (not just profile) and that you're logged into an account with a phone number linked directly to the Google account (not just Google+). It's easy to overlook the scope selection here, which leads to missing account-level data.
内容的提问来源于stack exchange,提问作者Kyle MacNamara

