How can I get access to Google Cloud Storage using an access and a secret key

非 Y 不嫁゛ 提交于 2020-03-05 03:25:09

问题


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 */
 }
}

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.


回答1:


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".

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.



来源:https://stackoverflow.com/questions/55176694/how-can-i-get-access-to-google-cloud-storage-using-an-access-and-a-secret-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!