【问题标题】:Want to access Google Cloud Datastore with embedded credentials想要使用嵌入式凭据访问 Google Cloud Datastore
【发布时间】:2014-05-15 16:57:30
【问题描述】:

我有一个 Java 应用程序,我想将其用户数据存储在 Google Cloud Datastore 中。入门教程中给出的步骤提到将凭据添加到环境,但这对于最终用户来说似乎不是一个好的解决方案。我想做的是从一组嵌入式凭据(一个文件或一组字符串)生成到数据库的连接。这样我就可以在用户继续正常使用应用程序的同时管理后台凭据。

有没有办法创建 DatastoreService 对象并手动传递凭据而不是使用 .getCredentialsFromEnv() 方法?

【问题讨论】:

    标签: java google-cloud-datastore nosql


    【解决方案1】:

    是的,你可以使用.getServiceAccountCredential

      /**
       * Constructs credentials for the given account and key.
       *
       * @param account the account to use.
       * @param privateKeyFile the file name from which to get the private key.
       * @return valid credentials or {@code null}
       */
      public static Credential getServiceAccountCredential(String account, String privateKeyFile) {
        ...
      }
    

    【讨论】:

      猜你喜欢
      • 2019-02-17
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      • 2017-05-07
      • 1970-01-01
      • 1970-01-01
      • 2014-12-18
      • 2020-01-22
      相关资源
      最近更新 更多