I am implementing Google One tap and I am not understanding how to get the id of a user who has already authorize my application refresh or close the windows and reopen it again. My console is empty, but I can see that Google authentifies him. Here is my Google One tap code :
window.onload = function () {
google.accounts.id.initialize({
client_id: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com',
auto_select: true,
callback: data => handleCredentialResponse(data),
state_cookie_domain: 'https://www.healxxxxxxxx.cm',
});
google.accounts.id.prompt((notification) => {
if (notification.isNotDisplayed() || notification.isSkippedMoment()) {
// try next provider if OneTap is not displayed or skipped
}
});
}
function handleCredentialResponse(response) {
//console.log(response)
user = parseJwt(response.credential);
console.log("ID: " + user.sub);
console.log('Full Name: ' + user.name);
console.log("Email: " + user.email);
console.log(JSON.stringify(parseJwt(response.credential)));
}
The code is supposed to ask authentication onload of the page. As soon as the user authorizes the app to get informations, I can see them via the function handleCredentialResponse. But when reloading the page and authorization already given, how I get the data of the user ?
If I se session, closing the browser will throw all informations. If I use cookies, I will be unable to use it on another browser. So how to read the data of the connected user who has already authorize my app ?