I am working on adding a Google login button to a website. Google docs offers two options: the "base" button:
https://developers.google.com/identity/sign-in/web/sign-in
and the "custom" button with signin2.render() :
https://developers.google.com/identity/sign-in/web/build-button
The problem I am facing is that two buttons exhibit different behavior. If I log in using any button, the "title" button changes from "Sign In" to "Signed In" to reflect the login status. However, if I am refreshing the page now, then the main button retains the “Signature” heading, and the user button changes its heading to “Login”, suggesting (incorrectly) that the login status has changed through the refresh page.
If I manually check the login status after updating in the browser console by running:
auth = gapi.auth2.getAuthInstance() auth.isSignedIn.get()
I get true as a return, showing that the update did not really change the login status, as opposed to changing the name of the button.
So my question is: how can I make a custom button behave like a basic button so that its name does not change during the update? Another (related, I guess) behavior of the base button that I like is that the "onsuccess" call is called every time the page loads (if the user is registered), while the user button does not. Therefore, I would also like to change this behavior on a custom button so that it matches the main button. Any suggestions would be greatly appreciated!
The parameters I pass are as follows:
function renderButton() { gapi.signin2.render('mybutton', { 'scope': 'profile email', 'width': 125, 'height': 40, 'longtitle': false, 'theme': 'light', 'onsuccess': onSuccess, 'onfailure': onFailure }); }