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

查看:110
本文介绍了如何使用访问权限和密钥访问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 */
 }
}

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

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");

真的很感谢您的帮助.

推荐答案

如您在

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天全站免登陆