![](/img/trans.png)
[英]Credentials Java application connect to google cloud datastore
[英]Want to access Google Cloud Datastore with embedded credentials
我有一个Java应用程序,要在Google Cloud Datastore中存储用户数据。 入门教程中给出的步骤提到将凭据添加到环境中,但这对于最终用户而言似乎不是一个好的解决方案。 我想做的是根据一组嵌入式凭据(文件或字符串集)生成与数据库的连接。 这样一来,我可以在用户仅按常规使用应用程序的情况下管理凭据。
有没有一种方法可以创建DatastoreService
对象并手动传递其凭据,而不是使用.getCredentialsFromEnv()方法?
是的,您可以使用.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) {
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.