简体   繁体   English

应用程序默认凭据无法创建Google App Engine服务帐户凭据

[英]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.

相关问题 Google App Engine中的默认凭据:无效凭据错误 - Default Credentials in Google App Engine: Invalid Credentials error Google Cloud Storage API无法在App Engine上获取应用程序默认凭据,以查找Compute Engine错误 - Google Cloud Storage API cannot get Application Default Credentials on App Engine looking for Compute Engine error 使用 IntelliJ IDEA 进行调试时如何将服务帐户凭据添加到 Google App Engine? - How to add service account credentials to Google App Engine when debugging with IntelliJ IDEA? 为 gmail API 创建服务帐户凭据 - Create service account credentials for gmail API Google Dialogflow:应用程序默认凭据不可用 - Google Dialogflow: The Application Default Credentials are not available 应用程序默认凭据不可用。 如果在 Google Compute Engine 中运行,它们就可用。 否则 - java android - The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise - java android 应用程序默认凭据不可用 - Application Default Credentials not available 如何为Google Compute Engine设置GOOGLE_APPLICATION_CREDENTIALS? - How to set GOOGLE_APPLICATION_CREDENTIALS for Google Compute Engine? 在续订凭据和应用访问Google帐户后授权范围 - Authorize scopes after renewing credentials and app access to google account GAE 凭据在 App Engine 上不可用 - GAE credentials not available on App Engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM