Wednesday, 26 August 2020

firing function from Google sign in button when user is already signed into browser

I am trying to have a Google Sign in on my website.

At present if you are already signed into the browser the button will say 'signed in' and the g_login() function will fire.

If you are not signed into the browser, it will say 'sign in' and clicking on it will fire the onSignIn() function which will then sign you in. In this case you then have to click the button again to fire the g_login() function.

How can I get the g_login() function to fire after the onSignIn() function if the button is clicked but not fired automatically without a user clicking on the button if they are already signed into the browser?

function onSignIn(googleUser){
    g_profile = googleUser.getBasicProfile();
}
function g_login(){
    var user_id = g_profile.getId();
    var user_name = g_profile.getName();
    var user_email = g_profile.getEmail();
    
    //do stuff
}

<div class="g-signin2" data-onsuccess="onSignIn" onclick="g_login();">


from firing function from Google sign in button when user is already signed into browser

No comments:

Post a Comment