Google 登录 - 访问令牌、身份验证令牌和 JWT ID 令牌之间的区别
Google Sign In - Difference between Access Token, Authentication Token and JWT ID Token
我在我的网络应用程序中使用 OAuth Flow。我的网络应用程序与 Google 日历 API 交互,用户通过使用 Google 登录(使用他们的 Gmail 帐户)进行身份验证。
我只是想确保我对身份验证令牌和访问令牌的理解和使用是正确的:
仅在登录期间需要 JWT ID 令牌。我们只需要在登录期间验证一次,如下所示:client.verifyIdToken({idToken: token, audience: CLIENT_ID})
。 ID 令牌不用于向 My Web App 的用户进行身份验证。参考:https://developers.google.com/identity/sign-in/web/backend-auth
此 JWT ID 令牌与我传递到我的 Web 应用程序的安全(已验证)端点的身份验证令牌完全不同。 Authentication Token 代表用户的会话,它可以使用任何库生成(即。crypto.generateRandomNumber()
)。
另一方面,我会有很多访问令牌,我用它来访问第三方 API(即 Slack API、Google 日历 API)。这些访问令牌不同于上面提到的 JWT ID 令牌和身份验证令牌。
我的 understanding/implementation 正确吗?有一次,我实际上是在使用我的 Google Calendar API Access Token 作为我的 Web App 的 Authentication Token,但是意识到这可能是错误的。 Access 令牌会 授权 用户使用 Google/Third-Party APIs,但我需要一个单独的 Authentication Token Authenticate users into My Web App.
The JWT ID Token is only needed during Sign-in
更正这叫做 Open Id connect, id 令牌用于验证计算机后面的用户是帐户的所有者,因为他们知道登录名和密码。把它当作你的出生证明,它证明你就是你。
This JWT ID Token is completely different from the Authentication Token
正确的 ID 令牌或开放 ID 连接建立在用于授权的 Oauth2 之上。
The Authentication Token represents a user's session, and it can be generated using any library.
在某些情况下,不正确的 Oauth2 允许您的应用程序请求已通过 Open id connect 进行身份验证的用户的同意,以授予应用程序访问其数据的权限。它与会话无关。使用访问令牌,您的应用程序可以在一段时间内访问数据。使用刷新令牌,您的应用程序将能够在过期时请求新的访问令牌。考虑身份验证更像是您的驾驶执照,您有权驾驶汽车。
I will have many Access Tokens, which I use to access third-party APIs
更正每个第三方 api 都有自己的授权服务器。您的应用需要由他们注册,他们会为您提供客户端 ID 和密码,您可以使用它们生成访问令牌以通过他们的 api.
访问您的用户数据
客户端 ID + 客户端密码 + 用户同意 = 范围授予
的 api 的访问令牌和刷新令牌
At one point, I was actually using my Google Calendar API Access Token as my Web App's Authentication Token, but realized this may be wrong.
Pre open id connect 这可能发生过很多次,现在仍然如此。
The Access Token would Authorize a user to use Google/Third-Party APIs, but I need a separate Authentication Token to Authenticate users into My Web App.
从技术上讲是的。但是,如果您有一个内部登录系统,您的用户在您的系统中创建帐户,这就是您在那里的身份验证,您只需请求对用户 google 帐户的额外授权,您可以将他们的刷新令牌存储为内部身份验证的一部分.
您可以使用多个身份验证提供程序(Facebook、twitter、google),但最好有一个内部的身份验证提供程序将它们全部映射在一起,否则用户最终可能会在您的系统中拥有三个帐户。
我在我的网络应用程序中使用 OAuth Flow。我的网络应用程序与 Google 日历 API 交互,用户通过使用 Google 登录(使用他们的 Gmail 帐户)进行身份验证。
我只是想确保我对身份验证令牌和访问令牌的理解和使用是正确的:
仅在登录期间需要 JWT ID 令牌。我们只需要在登录期间验证一次,如下所示:
client.verifyIdToken({idToken: token, audience: CLIENT_ID})
。 ID 令牌不用于向 My Web App 的用户进行身份验证。参考:https://developers.google.com/identity/sign-in/web/backend-auth此 JWT ID 令牌与我传递到我的 Web 应用程序的安全(已验证)端点的身份验证令牌完全不同。 Authentication Token 代表用户的会话,它可以使用任何库生成(即。
crypto.generateRandomNumber()
)。另一方面,我会有很多访问令牌,我用它来访问第三方 API(即 Slack API、Google 日历 API)。这些访问令牌不同于上面提到的 JWT ID 令牌和身份验证令牌。
我的 understanding/implementation 正确吗?有一次,我实际上是在使用我的 Google Calendar API Access Token 作为我的 Web App 的 Authentication Token,但是意识到这可能是错误的。 Access 令牌会 授权 用户使用 Google/Third-Party APIs,但我需要一个单独的 Authentication Token Authenticate users into My Web App.
The JWT ID Token is only needed during Sign-in
更正这叫做 Open Id connect, id 令牌用于验证计算机后面的用户是帐户的所有者,因为他们知道登录名和密码。把它当作你的出生证明,它证明你就是你。
This JWT ID Token is completely different from the Authentication Token
正确的 ID 令牌或开放 ID 连接建立在用于授权的 Oauth2 之上。
The Authentication Token represents a user's session, and it can be generated using any library.
在某些情况下,不正确的 Oauth2 允许您的应用程序请求已通过 Open id connect 进行身份验证的用户的同意,以授予应用程序访问其数据的权限。它与会话无关。使用访问令牌,您的应用程序可以在一段时间内访问数据。使用刷新令牌,您的应用程序将能够在过期时请求新的访问令牌。考虑身份验证更像是您的驾驶执照,您有权驾驶汽车。
I will have many Access Tokens, which I use to access third-party APIs
更正每个第三方 api 都有自己的授权服务器。您的应用需要由他们注册,他们会为您提供客户端 ID 和密码,您可以使用它们生成访问令牌以通过他们的 api.
访问您的用户数据客户端 ID + 客户端密码 + 用户同意 = 范围授予
的 api 的访问令牌和刷新令牌At one point, I was actually using my Google Calendar API Access Token as my Web App's Authentication Token, but realized this may be wrong.
Pre open id connect 这可能发生过很多次,现在仍然如此。
The Access Token would Authorize a user to use Google/Third-Party APIs, but I need a separate Authentication Token to Authenticate users into My Web App.
从技术上讲是的。但是,如果您有一个内部登录系统,您的用户在您的系统中创建帐户,这就是您在那里的身份验证,您只需请求对用户 google 帐户的额外授权,您可以将他们的刷新令牌存储为内部身份验证的一部分.
您可以使用多个身份验证提供程序(Facebook、twitter、google),但最好有一个内部的身份验证提供程序将它们全部映射在一起,否则用户最终可能会在您的系统中拥有三个帐户。