Reputation: 95
I have created a bucket on Google Cloud which contains one JSON file. I wish to access this JSON via some BASIC form of authentication, such as an API key
I have created an API key on google cloud with no restrictions
When I attempt a GET request using my API key, in the documented format, for example:
https://storage.googleapis.com/BUCKETNAME/JSONNAME?API_KEY=APIKEYNAME
It returns the following
"Anonymous caller does not have storage.objects.get access to bucket"
I am not sure why, since I am sending the API key
As an alternative, if I make the bucket/JSON file "public", I can access the JSON easily, via the following URL:
https://storage.googleapis.com/BUCKETNAME/JSONNAME
I don't really want to leave it completely open though..
Is there anything I can do here? I would like a basic key to be required (either on header or URL) to access the JSON
Thanks!
Upvotes: 0
Views: 2852
Reputation: 439
No, you can not use basic key to access file on private
Google Cloud Storage bucket.
There are two options to access file in private bucket.
1. Downloading object in Google Cloud Storage.
2. Signing URL to access file on your program.
Upvotes: 0
Reputation: 317352
According to the documentation on API keys:
After you have an API key, your application can append the query parameter key=yourAPIKey to all request URLs.
In your question, you said you're passing the API key with a parameter called "API_KEY", but the documentation says to use "key".
Upvotes: 1