gpt4 book ai didi

google-signin - 我可以在我的数据库中保存哪些数据以使用 Google 登录 API 验证用户?

转载 作者:行者123 更新时间:2023-12-04 05:48:02 26 4
gpt4 key购买 nike

我需要在我的数据库中存储与(谷歌)用户相关的数据。我试图存储 id_token,但后来发现 '.' 后面的部分改变了。可以用什么代替,或者我可以只保存“。”前面的部分。来自 id_token?

最佳答案

谢谢史蒂文·索尼夫

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



ID token 由三部分组成; header 、正文和签名,以“.”分隔。 (header.body.signature)。每个部分都使用 base64 编码。如果你解码正文,你会得到一个这样的 JSON:
{  
"iss":"https://accounts.google.com",
"at_hash":"xxx",
"aud":"xxx.apps.googleusercontent.com",
"sub":"xxx",
"email_verified":true,
"azp":"xxx.apps.googleusercontent.com",
"email":"xxx@gmail.com",
"iat":xxx,
"exp":xxx
}

...you can safely retrieve and use the user's unique Google ID from the sub claim



所以你可以保存 sub在您的数据库中识别您的用户

关于google-signin - 我可以在我的数据库中保存哪些数据以使用 Google 登录 API 验证用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36989373/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com