google / google-api-javascript-client

Google APIs Client Library for browser JavaScript, aka gapi.
Apache License 2.0
3.21k stars 1.06k forks source link

Unable to obtain phoneNumbers #327

Open adobs opened 7 years ago

adobs commented 7 years ago

With the following discovery and scope, I am successfully able to obtain 'names' and 'emailAddresses'. However, I am unable to obtain 'phoneNumbers'.


var DISCOVERY_DOCS = [
            "https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest", 
            "https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest", 
            "https://people.googleapis.com/$discovery/rest?version=v1"

        // Authorization scopes required by the API; multiple scopes can be
        // included, separated by spaces.
        var SCOPES = "https://www.googleapis.com/auth/gmail.send " + 
                     "https://www.googleapis.com/auth/calendar " + 
                     "profile";

gapi.client.people.people.get({
                    resourceName: 'people/me',
                    personFields: 'phoneNumbers'
                })

This yields the following error: "Requested entity was not found."

However, gapi.client.people.people.get({ resourceName: 'people/me', personFields:'names'}) .then(function(response) { userFirstName = response.result.names[0].givenName; userLastName = response.result.names[0].familyName; }); gapi.client.people.people.get({ resourceName: 'people/me', personFields: 'emailAddresses'}) are successful.

Please advise how I can obtain phoneNumbers. Thanks

Chfaisalnazir commented 6 years ago

Hi you cannot obtain phone number from google people api

benzilonka commented 6 years ago

have you found a solution yet?

martinnaj commented 1 year ago

Found it! Google have changed the profile page, and so the field you are looking for is the contact number, not the person's about me phone number