Search code examples
google-cloud-storage

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


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.


Solution

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