我正在尝试使用Java客户端库访问Google表格。首次访问令牌和刷新令牌已生成并存储在File。(StoredCredential
)中。访问令牌过期后,将不会使用“刷新令牌”生成新令牌。请建议可以做什么。
示例代码:
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
.setAccessType("offline")
.build();
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");