为什么访问令牌过期? [英] Why do access tokens expire?

查看:204
本文介绍了为什么访问令牌过期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Google API和OAuth2。当客户授权我的应用时,我会得到一个刷新令牌和一个短暂的访问令牌。现在,每次访问令牌过期时,我都可以将我的刷新令牌发送给Google,他们会给我一个新的访问令牌。

I am just getting started working with Google API and OAuth2. When the client authorizes my app I am given a "refresh token" and a short lived "access token". Now every time the access token expires, I can POST my refresh token to Google and they will give me a new access token.

我的问题是访问令牌过期?为什么不能有一个持久的访问令牌,而不是刷新令牌?

My question is what is the purpose of the access token expiring? Why can't there just be a long lasting access token instead of the refresh token?

另外,刷新令牌是否过期?

Also, does the refresh token expire?

有关Google的更多信息,请参见使用OAuth 2.0访问Google API OAuth2工作流程。

See Using OAuth 2.0 to Access Google APIs for more info on Google OAuth2 workflow.

推荐答案

这是非常多的实现特定的,但总体思路是允许提供商发布短期访问令牌长期刷新令牌。为什么?

This is very much implementation specific, but the general idea is to allow providers to issue short term access tokens with long term refresh tokens. Why?


  • 许多提供商支持承载令牌,这些令牌在安全性方面非常弱。通过使它们短暂并需要刷新,它们限制了攻击者滥用盗取令牌的时间。 大规模部署不希望在每次API调用时执行数据库查找,所以相反,他们发出可以通过解密验证的自编码访问令牌。但是,这也意味着无法撤销这些令牌,因此它们会在短时间内发布并且必须刷新。

  • 刷新令牌需要客户端身份验证,这使其更加强大。与上述访问令牌不同,它通常是通过数据库查找来实现的。

这篇关于为什么访问令牌过期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆