How can I get birthday and phone number information from the Google API?

508 views Asked by At

I can successfully get some Google profile information using the following code:

googlePlusInit: function() {
    var googleUser = {};
    gapi.load('auth2', function(){
        // Retrieve the singleton for the GoogleAuth library and set up the client.
        auth2 = gapi.auth2.init({
            client_id: '309999495252-2j0c662keglco3na7pnb3fl66b3p1v31.apps.googleusercontent.com',
            cookiepolicy: 'single_host_origin',
            scope: 'https://www.googleapis.com/auth/user.phonenumbers.read https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/user.birthday.read'
        });
        sanObj.googlePlusSign(document.getElementById('g-plus-sign'));
    });
},

googlePlusSign: function(element){
    //console.log(element.id);
    auth2.attachClickHandler(element, {},
        function(googleUser) {
            console.log(googleUser.getBasicProfile().getGivenName());
            console.log(googleUser.getBasicProfile().getFamilyName());
            console.log(googleUser.getBasicProfile().getEmail());   
            sanObj.apiClientLoaded()            
        }, 

        function(error) {
          alert(JSON.stringify(error, undefined, 2));
        }

    );
},

apiClientLoaded: function() {
    gapi.client.load('plus', 'v1', function() {
        var request = gapi.client.plus.people.get({'userId': 'me'});
        request.execute(function(resp) {
            console.log(resp);

        });
    });
},

In the resp of request.execute I can see some profile information but not birthday and phone number, although my test profile does contain this information.

How can I obtain this information from this api call?

0

There are 0 answers