【发布时间】:2019-01-16 12:13:49
【问题描述】:
我既在本地,也在我们的 Kubernetes pod 中,通过了 Google 云的身份验证。在这两种情况下,我都可以通过gcloud info 得到正确的回复。
但是,当我想访问 GoogleDrive 时,我需要使用 GoogleCredential,如下所示:
GoogleCredential.Builder()
.setTransport(transport)
.setJsonFactory(jsonFactory)
.setServiceAccountPrivateKey(privateKey)
.setServiceAccountId(serviceAccount)
.setServiceAccountScopes(scopes.toList()).build()
含义——我需要专门设置privateKey和serviceAccount。有没有办法强制它使用本地认证的账号?
使用 Google 存储桶时,这很容易做到:
StorageOptions.getDefaultInstance().service.options.credentials
我无法为 Google Drive 找到相同的方法。
【问题讨论】:
-
我认为不是,有点遗憾。您喜欢 GCS 的功能称为应用程序默认凭据,但据我所知,仅限于 Google Cloud Platform 库(因此不包括 Google Drive)。
标签: java google-drive-api gcloud google-kubernetes-engine