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

标签 authentication oauth-2.0 youtube-api access-token refresh-token

我有一个与 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/

相关文章:

wpf - WPF 中的身份验证和角色

asp.net - ASP.NET内网网站IIS跨域集成windows身份验证

python - OAuthException : Invalid response from google

android - Youtube Player APi android启用上下文菜单

php - 用户登录后如何处理额外的登录尝试?

ruby-on-rails - 使用 rspec_api_documentation 清除 Doorkeep token

javascript - oauth2Client.getToken 缺少 refresh_token

android - 按下网页 View 中嵌入式YouTube fragment 中的播放按钮,启动YouTube应用

actionscript-3 - 如果在自己的域上播放,如何播放YouTube视频

java - 如何通过 Android 的帐户管理器类检索 Twitter 和 facebook 身份验证和 token