简体   繁体   English

Google云端硬盘会话有效期

[英]Google Drive Session Expiry

From my understanding, when using the Drive Java API it is recommended to build an instance of the Drive class and then store it so that it can then be shared by other threads. 根据我的理解,在使用Drive Java API时,建议构建Drive类的实例,然后将其存储,以便其他线程可以共享它。 If the process that holds this reference to the Drive instance is a long running processes (ie indefinite) will the session (?) eventually expire and require authentication again, or are the credentials passed with every request? 如果持有对Drive实例的此引用的进程是长时间运行的进程(即无限期),会话(?)最终是否会过期并需要再次进行身份验证,还是每次请求都会传递凭据?

The Drive API uses OAuth 2.0 as the authorization mechanism and that involves passing an access token with every request. Drive API使用OAuth 2.0作为授权机制,并涉及为每个请求传递访问令牌。

Access tokens are short-lived and expire after about 1 hour. 访问令牌是短暂的,并在约1小时后过期。 When that happens, your application has to request a new access token by using the refresh token that is retrieved the first time the user authorizes the app. 发生这种情况时,您的应用程序必须使用在用户第一次授权应用程序时检索的刷新令牌来请求新的访问令牌。

All of this is performed automatically by the Java client library for Google Drive and is documented at https://developers.google.com/drive/about-auth 所有这些都由Google云端硬盘的Java客户端库自动执行,并在https://developers.google.com/drive/about-auth中进行了说明

The documentation also includes a complete Java sample application for Google Drive that you can use as reference: 该文档还包括一个完整的Google Drive Java示例应用程序,您可以将其用作参考:

https://developers.google.com/drive/examples/java https://developers.google.com/drive/examples/java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM