【发布时间】:2019-04-26 17:51:35
【问题描述】:
我正在开发一个应用程序,该应用程序使用部署在 AppEngine 上的休息端点启动 Google VM 实例。
在初始化 Compute Engine API 时,我提供了应用程序默认凭据(因为我希望这将返回 AppEngine 服务帐户凭据)
GoogleCredential credential = GoogleCredential.getApplicationDefault();
if (credential.createScopedRequired()) {
List<String> scopes = new ArrayList<>();
// Set Google Compute Engine scope to Read-write.
scopes.add(ComputeScopes.COMPUTE);
credential = credential.createScoped(scopes);
}
return new Compute.Builder(httpTransport(), jsonFactory(), credential)
.setApplicationName(env.getProperty("spring.application.name"))
.build();
但我最终得到了错误:
java.io.IOException: Application Default Credentials failed to create the Google App Engine service account credentials
我正在使用库:
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>${google-api-client.version}</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-compute</artifactId>
<version>${google-api-services-compute.version}</version>
</dependency>
【问题讨论】:
标签: java google-app-engine google-cloud-platform google-compute-engine