如何使用访问权限和密钥访问 Google Cloud Storage [英] How can I get access to Google Cloud Storage using an access and a secret key

查看:24
本文介绍了如何使用访问权限和密钥访问 Google Cloud Storage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有 Google Cloud Storage 的访问权限和密钥,我想使用这些凭据实例化客户端.我一直在看教程并遇到了这个例子:

I have access and a secret key to Google Cloud Storage and I want to instantiate a client using those credentials. I've been looking at tutorials and came across this example:

public class QuickstartSample {
public static void main(String... args) throws Exception {
// Instantiates a client
Storage storage = StorageOptions.getDefaultInstance().getService();
/* Perform some bucket action */
 }
}

有什么方法可以在实例化客户端时传递 accesssecret 密钥,其方式类似于 AWSMinio,类似这样:

Is there any way I could pass that access and secret key while instantiating a client, in a fashion similar to that of AWS and Minio, something like this:

minioClient = new MinioClient("server URL", "accessKey",
      "secretKey");

非常感谢您对此的帮助.

I'd really appreciate some help with this.

推荐答案

如你所见 此链接,使用 Google Cloud 客户端库时,您无需在代码中明确指定您的凭据".

As you can see in this link, "you don't need to explicitly specify your credentials in code when using a Google Cloud Client Library".

虽然有一些其他选项可以在您的代码中对您的客户端进行身份验证,但它们都没有使用访问和密钥,例如在 AWS 存储桶中发生的情况.这里您有许多选项可以在您的代码中实现该身份验证,例如就像在代码中使用 JSON 服务帐户密钥或使用 OAuth2 访问令牌一样.

There are though some other options to authenticate you client in your code, but none of them use access and secret key as it happens in AWS buckets, for instance. Here you have a number of options to implement that authentication in your code, such as using the JSON service account key within your code or using an OAuth2 access token.

这篇关于如何使用访问权限和密钥访问 Google Cloud Storage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆