0

I need help. I try to catch all of contacs from Google Api V3, Auth2, but it returns this error:

GET https://www.google.com/m8/feeds/contacts/default/full?callback=jQuery171029…+gsession&issued_at=1379496709&expires_at=1379500309&_aa=0&_=1379496719602 401
(Token invalid - AuthSub token has wrong scope)

First I Sign in Google +, and then i try to do the authorization in Google Contacts:

function myContacts() {
    var config = {
        'client_id': clientId,
        'scope': 'https://www.google.com/m8/feeds',
    };

    gapi.auth.authorize(config, function () {
        var authParams = gapi.auth.getToken(); // from Google oAuth
        $.ajax({
            url: 'https://www.google.com/m8/feeds/contacts/default/full',
            dataType: 'jsonp',
            type: "GET",
            data: authParams,
            success: function (data) {
                alert("success: " + JSON.stringify(data))
            },
            error: function (data) {
                console.log("error: " + JSON.stringify(data))
            }
        })
    });
}

Is this the correct way to do this?

Thank you

I.G. Pascual
  • 5,818
  • 5
  • 42
  • 58

2 Answers2

0

Append access_token into url as request parameter with the token fetched after authorization, instead of sending it to data.

sufyan.shoaib
  • 1,117
  • 9
  • 19
0

you can't do an hxr (ajax) request given the CORS restriction from goolge.com.

you can use this library to achieve this though. It solves the Oauth login/retrieving contacts from gmail)

http://eventioz.github.io/gcontacts/

Gago Ar
  • 97
  • 1
  • 3