I have some images in my Google Cloud Storage bucket and I would like to pass the image urls to the front-end for displaying on a web application. However I'm not quite sure how the authentication works. There seem to be 2 methods that seem feasible to me.
Using curl: https://cloud.google.com/storage/docs/downloading-objects#download-object-json
curl -X GET \ -H "Authorization: Bearer [OAUTH2_TOKEN]" \ -o "[SAVE_TO_LOCATION]" \ "https://www.googleapis.com/storage/v1/b/[BUCKET_NAME]/o/[OBJECT_NAME]?alt=media"
However, I could not manage to generate a jwt token from my service key created in Google IAM. Using jsonwebtoken couldn't seem to parse my json file, and when I extracted the private_key portion into a pem file, an error message would be thrown: Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
- Using signed-url: https://cloud.google.com/storage/docs/access-control/signed-urls
For this method, I'm not quite sure whether this is meant for my back-end server to pass a signed-url to the front-end for access, or whether it can be constructed on the front-end. Are there any security issues for doing so and are there any best practices?