I need to store data related to a (Google) user in my database. I tried to store the id_token, but later found out that the part after the '.' changed. What can be used instead, or can I just save the part infront of the "." from the id_token?
After you have signed in a user with Google using the default scopes, you can access the user's Google ID, name, profile URL, and email address.
Once Google discovers a page's URL, it may visit (or "crawl") the page to find out what's on it. We use a huge set of computers to crawl billions of pages on the web. The program that does the fetching is called Googlebot (also known as a robot, bot, or spider).
Thanks Steven Soneff
Use the 'sub' field of the ID token, it is invariant for the Google user https://developers.google.com/identity/sign-in/android/backend-auth#calling-the-tokeninfo-endpoint
The ID token have three parts; the header, body and signature, divided by a '.' (header.body.signature). Each part is encoded with base64. If you decode the body, you will get a JSON like this:
{
"iss":"https://accounts.google.com",
"at_hash":"xxx",
"aud":"xxx.apps.googleusercontent.com",
"sub":"xxx",
"email_verified":true,
"azp":"xxx.apps.googleusercontent.com",
"email":"[email protected]",
"iat":xxx,
"exp":xxx
}
...you can safely retrieve and use the user's unique Google ID from the sub claim
So you can save the sub
in your database to identify your user
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With