Yaman
Yaman

Reputation: 1061

Google People API gapi.client.people.people.connections.list returns Request had insufficient authentication scopes

Google People API gapi.client.people.people.connections.list returns error 403 with error message Request had insufficient authentication scopes even though the initialization includes the required scope

   gapi.client.init({
            apiKey: '***masked***',
            discoveryDocs: ["https://people.googleapis.com/$discovery/rest?version=v1"],
            clientId: "***masked***.apps.googleusercontent.com",
            'scope': "https://www.googleapis.com/auth/contacts.readonly"
        });

the request looks like this

api.client.people.people.connections.list({
        'resourceName': 'people/me',
        'personFields': 'names,emailAddresses'
    }).then(function (response) {
        console.log(response.result.emailAddresses[0].value);
        if (importGmailCallback) {
            importGmailCallback(response);
        }
    }, function (reason) {
        console.log('Error: ' + reason.result.error.message);
    });

Waiting for sign in changes happens here

Promise.resolve(window.gapi.auth2.getAuthInstance().signIn()).then(function () {
        // Listen for sign-in state changes.
        gapi.auth2.getAuthInstance().isSignedIn.listen(googlePeopleSignedInCallback);
        // Handle the initial sign-in state.
        googlePeopleSignedInCallback(gapi.auth2.getAuthInstance().isSignedIn.get());
    }, function (error) {
        console.log(error);
    });

I had a success using similar values in API Explorer, tried to remove access and re-authenticated, deleted all cookies, but no luck

Upvotes: 4

Views: 1240

Answers (2)

MMM
MMM

Reputation: 113

Try to add this scope as well: "https://www.google.com/m8/feeds"

Upvotes: 0

Innocent Criminal
Innocent Criminal

Reputation: 196

Try removing the inverted commas in scope.

Replace:

'scope':"https://www.googleapis.com/auth/contacts.readonly"

with

scope:"https://www.googleapis.com/auth/contacts.readonly"

Upvotes: 1

Related Questions