java - Google App Engine - 未找到 GoogleCredential.getApplicationDefault(transport, jsonFactory)

标签 java google-app-engine google-cloud-storage

我需要使用 Google App Engine 中的 Google 云存储。为此,我尝试使用应用程序默认凭据来获取授权凭据以连接到 Cloud Storage API。我使用 add Google Api 选项在 eclipse 中添加了 Google Cloud Storage JSON API。它添加了 google-api-client-1.18.0-rc.jar。这个jar没有下面的方法。

GoogleCredential credential = GoogleCredential.getApplicationDefault(transport, jsonFactory);

当我看到示例时,我看到下面的依赖项

<dependency>
      <groupId>com.google.apis</groupId>
      <artifactId>google-api-services-storagetransfer</artifactId>
      <version>v1-rev1-1.20.0</version>
    </dependency>

但是在 Eclipse 中,在使用添加 Google API 窗口时,我没有找到找到此“v1-rev1-1.20.0”版本的 Google Cloud Storage API 的方法。如何下载与 v1-rev1-1.20.0 版本兼容的 Google Cloud Storage API jar?

最佳答案

由于您是从 App Engine 访问 Cloud Storage,因此您可以使用为 App Engine 构建的 GCS 客户端:

GcsService gcsService = GcsServiceFactory.createGcsService();
// ...
ListResult objects = fileService.list(MY_BUCKET_NAME, ListOptions.DEFAULT);
// ... and so on

关于java - Google App Engine - 未找到 GoogleCredential.getApplicationDefault(transport, jsonFactory),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38593324/

相关文章:

java - build.xml 中的 include 标记中指定的文件不会添加到 jar 中

java - Drools Java 内存不足错误

java - 如何在 Java 中解析 JSON 字符串中的项目

python - 应用引擎 : submitting form data to Google Spreadsheet

google-cloud-platform - 谷歌云平台 : accumulate data from Pub/Sub to files in Cloud Storage without Dataflow

firebase - 连接到 Firebase 存储桶

java - 无法将蓝牙设备列为列表

python - dev_appserver.py 没有重新加载更改的代码

java - 从命令行运行 AppEngine

google-cloud-platform - GCS : Manually trigger "object created" event