In the process of creating a prototype with two basic pages and Google Plus integration, I encounter an issue. The first page includes a "login" button, while the second has a link. Upon clicking the login button, the following code is executed:
var params = {"client_id":"<client_id>", "scope":"https://www.googleapis.com/auth/plus.login"};
gapi.auth.authorize(params, signinCallback);
The signinCallback
function is structured like this:
var signinCallback = function(authResult) {
if (authResult['access_token']) {
gapi.auth.setToken(authResult);
gapi.client.load('plus','v1', function(){
var request = gapi.client.plus.people.list({
'userId': 'me',
'collection': 'visible'
});
request.execute(function(resp) {
console.log(resp);
});
});
} else if (authResult['error']) {
console.error('Sign-in state: ' + authResult['error']);
}
}
Upon successful sign-in and permission granting by the user, the token is stored for future calls to obtain a people list, which functions properly.
However, upon transitioning to the second page and attempting to make the same API call as before:
gapi.client.load('plus','v1', function(){
var request = gapi.client.plus.people.list({
'userId': 'me',
'collection': 'visible'
});
request.execute(function(resp) {
console.log(resp);
});
});
An error occurs with the message:
Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.
I assumed that using "setToken" after initial authentication should bypass the need for authentication for subsequent calls. What could be possibly going wrong in my implementation?