Reputation: 506
I understand that if you set an object in a bucket as public-read then everyone can access it by sending a GET request to https://storage.googleapis.com/{bucket}/{file}. If now I want to set read permission only to authenticated users what is the simplest way to do that? For example I want a mobile app to send json requests to the above url and read the files. It seems like I need to provide an authorized e-mail or token, that has been set up in Google cloud console. But how to I add that to the request?
Upvotes: 0
Views: 211
Reputation: 38399
The easiest way is to provide a signed URL to the authenticated user. Documentation here:
https://developers.google.com/storage/docs/accesscontrol#Signed-URLs
Any user who has the URL will be able to read that object for a certain amount of time. Your server can give them out like temporary passwords to download objects.
Upvotes: 1