使用google的auth2 api时,是否可以提交一个nonce或state

When using google's auth2 api, is it possible to submit a nonce or state

我正在使用 Google Sign-in for websites api 并且想提交一个随机数并在签名的 JWT id_token 中返回它(在 JTI 字段中)。

google identity platform 提到了随机数和状态字段,但其中 none 似乎与 auth2 api 一起使用。使用 auth2 发送和接收此值的正确方法是什么?

根据评论中的讨论,我看到您正在尝试混合使用原始 OAuth 协议和 Google 登录库。 虽然 this page 中提到的东西(例如随机数或状态)是 OAuth 协议的一部分,但 Google 登录是一个 JavaScript 库,可以简化事情。

使用 Google 登录,您可以让用户仅使用 JavaScript 登录。如果你想和服务器集成,发送id_token你可以从JSAPI获取到服务器。可以在以下资源中找到更多信息。

Google 登录网站: