I'm working on an app that starts Google VM instances using a rest endpoint deployed on AppEngine.
when initializing Compute Engine API, I provide the application default credential (since I'm expecting that this will return the AppEngine service account credentials)
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>