I have installed Google Login Button in this website that already have Facebook Login. First, the library:
<script src="https://accounts.google.com/gsi/client" async defer></script>
Than the button:
<div id="g_id_onload"
data-client_id="myid.apps.googleusercontent.com"
data-context="signin"
data-ux_mode="popup"
data-callback="loginGoogle"
data-auto_prompt="false">
</div>
<div class="g_id_signin"
data-type="standard"
data-shape="rectangular"
data-theme="filled_blue"
data-text="signin_with"
data-size="large"
data-logo_alignment="left">
</div>
Finally the callback function
var loginGoogleRes;
function loginGoogle(response) {
loginGoogleRes = parseJwt(response.credentials);
loginLogar("google");
}
But there is still the jwd parser...
function parseJwt(token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
return JSON.parse(jsonPayload);
}
And at this point token is null, therefore loginGoogle is receiving null value. Before this null issue, the button works ok, ask for my permission, etc, but it will stop here. Maybe some async method, I am also struggling with Dreamweaver that won't work with async methods, plus I'm kinda lost in Google's documentation, it is my first time. Can you help me?