[英]Application Default Credentials fails to create the Google App Engine service account credentials
I'm working on an app that starts Google VM instances using a rest endpoint deployed on AppEngine. 我正在开发一个使用部署在AppEngine上的剩余端点启动Google VM实例的应用程序。
when initializing Compute Engine API, I provide the application default credential (since I'm expecting that this will return the AppEngine service account credentials) 初始化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();
But I end up with the error : 但是我最终遇到了错误:
java.io.IOException: Application Default Credentials failed to create the Google App Engine service account credentials
I 'm using libraries : 我正在使用库:
<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>
I solved this by using google-api-cient-appengine instead of google-api-client : 我通过使用google-api-cient-appengine而不是google-api-client解决了此问题:
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-appengine</artifactId>
<version>${google-api-client-appengine.version}</version>
</dependency>
and initialized GoogleCredential using : 并使用初始化了GoogleCredential :
GoogleCredential credential = AppEngineCredentialWrapper.getApplicationDefault();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.