'Where do I find my Google Cloud Storage Bucket access key?

I am trying to set up my Google Cloud Storage Bucket and need the JSON key structure, but I cannot find it. Where do I find the GCS access key?



Solution 1:[1]

I found it under IAM, but that is apparently not the recommended method of granting access. This is Google's recommended way

https://console.cloud.google.com/apis/credentials/consent?referrer=search&project=feisty-ward-341113

but leads to another question. I will ask in another thread.

Solution 2:[2]

GCS uses the same authentication credentials as the rest of Google Cloud (in addition to supporting a few special options, like HMAC keys). Authentication is a complicated subject with many options, so I'd suggest starting by reading through https://cloud.google.com/docs/authentication.

If you're looking at a JSON file, there's a good chance you've found the Credentials page of the cloud console and have acquired credentials file for either yourself or for a service account that you've created. This file contains a bunch of information about how to authenticate, which will either include a private key (for a service account) or an OAuth refresh token (for a user). Most Google Cloud tools know how to take these files and convert the credentials inside into an access token.

Access tokens only last a few minutes, but if you want to use one directly to make some ad-hoc calls yourself, there are easy ways to acquire one. The easiest is to open the cloud console, click the >_ button in the top right to open the cloud console, and then type gcloud auth print-access-token into the terminal. I sometimes like to test calls using cURL or HTTPie with a command like this:

curl -H "Authorization: Bearer `gcloud auth print-access-token`" https://...

But again, access tokens only last a few minutes, so for any long-running thing, you'll want to use some sort of tool that can handle authentication for you. Most programming languages have Google Cloud libraries that can take care of this for you, see: https://cloud.google.com/docs/authentication/production

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user3877654
Solution 2 Brandon Yarbrough