I am working on a function which allows users to sign in on my website with their Google account.
My code is based on the Google documentation (others signIn() options a
Try to register first call in some local variable and then process it
This quick solution helps me:
function login() {
var initializedGoogleCallback = false
gapi.auth.signIn({
'callback': function (authResult) {
if (!initializedGoogleCallback) {
// after first call other will be ignored
initializedGoogleCallback = true;
if (authResult['status']['signed_in']) {
console.log('Okay');
} else {
console.log('Error');
}
}
}
});
}
also you can add following code before call gapi.auth.signIn
window.removeEventListener('load')