gmail - gmail oauth2 的授权码是否会过期

标签 gmail oauth-2.0 gmail-imap aspose

我正在尝试使用 gmail smtp 使用 oauth 2.0 .我用过 aspose.dll 用于使用授权 url 请求访问 token 。当我收到响应时,我没有获得刷新 token 。因此,如果以前的访问 token 已过期,则无法请求新的访问 token 。所以我想每次我的应用程序需要时都获取访问 token 。如果授权码过期,那么我不能遵循这种方法。

gmail oauth2 的授权码会过期吗?

最佳答案

Google 的 OAuth 2.0 确实提供了刷新 token !!!这个link这里解释了各种流程,并讨论了应用程序获取所有场景的访问权限和可选的刷新 token 。
授权码会过期 !这就是 OAuth 协议(protocol)所规定的。我无法找到此处引用 Google 的确切时间段,但我知道 Facebook ),授权码在 10 分钟后过期(请参阅链接中的 12 月 5 日更改。)。刷新 token 可用于像您这样的用例。如果要保留授权代码,刷新 token 和授权代码之间会有什么区别。
我建议您查看您正在使用的 Aspose 库的文档。
PS - 授权码/访问 token /刷新 token 均由中央 Google 授权服务器发布!所以,我们谈论的是谷歌的授权码,正如我所说,它确实会过期。
祝你好运!
编辑 - 为您添加更多信息

     The authorization code generated by the
     authorization server.  The authorization code MUST expire
     shortly after it is issued to mitigate the risk of leaks.  A
     maximum authorization code lifetime of 10 minutes is
     RECOMMENDED.  The client MUST NOT use the authorization code
     more than once.  If an authorization code is used more than
     once, the authorization server MUST deny the request and SHOULD
     revoke (when possible) all tokens previously issued based on
     that authorization code.  The authorization code is bound to
     the client identifier and redirection URI.

来源 - https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-31
第 4.1.2 节

关于gmail - gmail oauth2 的授权码是否会过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16360998/

相关文章:

email - 使用 msmtp 通过终端发送邮件工作正常,但不适用于 php mail()

javax 无法将套接字转换为 TLS;

spring-boot - Spring Boot OAuth2 invalid_user_info_response

android - 如何在 Intent ACTION_SEND 中将超链接传递到 Gmail?

gmail - Google 聊天徽章不再起作用?

php - Symfony 3 应用程序的 Google Play Market 身份验证

google-api - 确定通过 Oauth2 登录的 Google Apps 用户的角色、群组或组织单位

c# - 如何使用 MailKit 删除 Gmail 中的邮件(不移至垃圾箱文件夹)

主题的 Javamail IMAP 搜索失败

按 UID 范围搜索 Gmail IMAP 似乎会跳过第一条消息