我需要在数据库中存储与(Google)用户相关的数据。我尝试存储id_token,但后来发现在“。”之后的部分。改变了。可以代替使用什么,也可以仅将零件保存在“。”前面。来自id_token?
谢谢史蒂文·索内夫
使用ID令牌的'sub'字段,对于Google用户https://developers.google.com/identity/sign-in/android/backend-auth#calling-the-tokeninfo-endpoint不变
ID令牌分为三个部分:标头,正文和签名,以“。”分隔。(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
}
Run Code Online (Sandbox Code Playgroud)
...您可以从子声明中安全地检索和使用用户的唯一Google ID
因此您可以将储存sub在资料库中以识别您的使用者
| 归档时间: |
|
| 查看次数: |
1102 次 |
| 最近记录: |