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

Mil*_*war 6 gmail aspose gmail-imap oauth-2.0

我正在尝试使用oauth 2.0来使用gmail smtp.我使用aspose.dll来使用授权URL请求访问令牌.当我得到响应时,我没有获得刷新令牌.因此,如果之前的过期,则无法请求新的访问令牌.所以我想到每次我的应用程序需要获取访问令牌.如果授权代码过期,那么我就无法遵循这种方法.

gmail oauth2的授权代码是否会过期?

div*_*shm 9

谷歌的OAuth 2.0提供刷新令牌!此链接说明了有关应用程序获取访问权限和所有方案的可选刷新令牌的各种流程和说明.

授权码DOES到期!这就是OAuth协议规定的内容.我找不到这里引用Google的确切时间段,但我确实知道,对于Facebook),授权代码会在10分钟后到期(请参阅链接中的12月5日更改).
刷新令牌已经可用于像您这样的用例.如果授权代码要持久化,则刷新令牌和授权代码之间仍然存在差异.

我建议你查看你正在使用的Aspose库的文档.

PS - 授权码/访问令牌/刷新令牌均由中央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.
Run Code Online (Sandbox Code Playgroud)

来源 - http://tools.ietf.org/html/draft-ietf-oauth-v2-31
第4.1.2节