I can't find any documentation on Google One Tap UX and how to retain logged in status after login redirect. I am using html api, please see the code here:
setTimeout(function () { let target = document.getElementById('google-signin'); target.innerHTML = '<div id="g_id_onload" data-client_id="x" data-context="signin" data-login_uri="https://x/account/google/callback" data-auto_select="true" data-itp_support="true"></div>'; var s = document.createElement("script"); s.src = 'https://accounts.google.com/gsi/client'; document.head.appendChild(s); console.log('appended script', s); }, 30000); </script>
Essentially, I delay this login popup for 30 seconds and that part works fine, but shortly after this happens:
I would have thought that the google sdk would set a cookie or something somewhere, but I guess it doesn't, or I should handle persistent login status my own way. I just want to know the correct approach here.
My question is: How does Google know if a user is logged in using Google One Tap UX?
Came up with a solution. Google allows you to place a div tag called
data-skip_prompt_cookie="yourcookie"
This will skip the one-click prompt if the cookie has a true value.What I did is in the server callback in asp.net I added a cookie to the response. This ensures that the prompt is only disabled after someone is actually logged in.
This ensures that when my server redirects back to the original page, the cookie is present and the one click doesn't happen again