Search code examples
javascriptcordovaphonegap-pluginsgoogle-contacts-api

Get contactlis from Google in Phonegap


I am trying to get user contact(email, name) list from Google in Phonegap, but getting error like:

There was an error in your request.

my code:

$http({
    method: 'GET',
    url: "https://www.google.com/m8/feeds/contacts/default/thin?alt=json&access_token=" + accessToken + "&max-results=500&v=3.0",
    headers: {
        'Content-Type': 'application/json'
    }
}).
success(function(res) {
    console.log("Success: " + JSON.stringify(res));

}).
error(function(err) {
    console.log("Error:" + err);

});

Solution

  • The access_token was granted without the proper API scope.

    When authenticating, one of the following scopes must be included:

    • Read/write: https://www.google.com/m8/feeds
    • Read-only: https://www.googleapis.com/auth/contacts.readonly

    Reference: https://developers.google.com/google-apps/contacts/v3/#authorizing_requests_with_oauth_20