如何验证Google身份服务的响应
我正在尝试使用Google登录用户,并且正在使用他们的身份服务,我在客户端使用以下代码。
google.accounts.id.initialize({
client_id:
"*********.apps.googleusercontent.com",
callback: handleCallback,
});
我得到的响应极为有限,因为在我获得
- clientId
- recertential
- select_by
中,在解码凭据之后,我将使用
- NBF
- AUD
- SUB
- AZP
- IAT
- JTI
获得基本用户信息,我不知道这些是什么。 因此,当我将这些信息发送到服务器时,我可以轻松存储它们并生成一个ID,以将其发送回客户端以使用Cookie记录它们。但是,当用户登录并恢复原状时,如何在服务器中不做多个条目?如何在数据库中检查新用户已经拥有一个帐户。我认为我无法将传入的电子邮件地址与数据库中存储的电子邮件地址匹配,因为那将是安全风险。我如何实际验证对服务器的请求?
I'm trying to log user in with google and I'm using their Identity Services, I used the following code in client side.
google.accounts.id.initialize({
client_id:
"*********.apps.googleusercontent.com",
callback: handleCallback,
});
The response I get is extremely limited as in I get
- clientId
- credential
- select_by
and after decoding the credentials I get basic user info with
- nbf
- aud
- sub
- azp
- iat
- jti
I have no idea what these are.
So when I send these information to my server, I can easily store them and generate a id to be sent back to the client to log them in using cookie. But when user logs out and logs back in how do I not make multiple entries in my server? How do I check in my database that the new user already has an account. I don't think I could match the incoming email address to the one stored in my database since that would be a security risk. How do I actually verify the request to my server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该阅读 verify ID iD token 在您使用哪个客户库的情况下,应该有一种可以调用的方法来验证它。
例如,java
在RFC rfc7519> rfc7519> rfc7519>
是您的魔术主张。这将告诉您用户内部Google ID,因此,如果您将其与系统中的用户帐户一起存储在系统中。您将始终能够链接它们。这称为帐户链接。
You should read though Verify id token Depending upon which client library you are using there should be a method that you can call to verify it.
Java for example
As for the claims have a look in the RFC rfc7519#section-4.1
Sub is your magic claim. This will tell you the users internal google id so if you store this in your system along with the users account on your system. You will always be able to link them. This is called account linking.