gpt4 book ai didi

authentication - "Refresh Token"的用途是什么?

转载 作者:行者123 更新时间:2023-12-03 07:34:09 30 4
gpt4 key购买 nike

我有一个与 YouTube Live Streaming API 集成的程序。它在计时器上运行,因此对我来说相对容易编程,使用刷新 token 每 50 分钟获取一个新的访问 token 。我的问题是,为什么?

当我通过 YouTube 进行身份验证时,它给了我一个刷新 token 。然后,我使用此刷新 token 大约每小时一次获取新的访问 token 。如果我有刷新 token ,我总是可以使用它来获取新的访问 token ,因为它永远不会过期。因此,我不认为这比从一开始就给我一个访问 token 而不打扰整个刷新 token 系统更安全。

最佳答案

基本上,刷新 token 用于获取新的访问 token 。

为了清楚地区分这两个标记并避免混淆,以下是The OAuth 2.0 Authorization Framework中给出的它们的功能。 :

  • Access tokens are issued to third-party clients by an authorization server with the approval of the resource owner. The client uses the access token to access the protected resources hosted by the resource server.
  • Refresh Tokens are credentials used to obtain access tokens. Refresh tokens are issued to the client by the authorization server and are used to obtain a new access token when the current access token becomes invalid or expires, or to obtain additional access tokens with identical or narrower scope.

现在,回答您的问题:为什么您仍然获得刷新 token 而不仅仅是保护访问 token ,这是互联网工程任务组在 Refresh tokens 中提供的主要原因。是:

There is a security reason, the refresh_token is only ever exchanged with authorization server whereas the access_token is exchanged with resource servers. This mitigates the risk of a long-lived access_token leaking in the "an access token good for an hour, with a refresh token good for a year or good-till-revoked" vs "an access token good-till-revoked without a refresh token."

有关 OAuth 2.0 流程的更详细、完整的信息,请尝试阅读以下引用资料:

关于authentication - "Refresh Token"的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38986005/

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