Per this documentation Addendum: Service account authorization without OAuth, it says
If the API you want to call has a service definition published in the Google APIs GitHub repository, you can make authorized API calls using a JWT instead of an access token
I see Google Cloud Storage published on that Github repository but I can not seem to be able to get a file on Google Cloud Storage with the approach in the documentation. According to JWT header and payload example show in step 3 of the documentation, I did the following adjustments
- Change
kidfromabcdef1234567890to my service accountprivate_key_id - Change
issandsubto my service accountclient_email - Change
audtohttps://storage.googleapis.com/ - Change
iatandexpto now and now + 1 hour
I use signed JWT as bearer token trying to get file from http://storage.googleapis.com/<bucket>/path/file but I keep getting this response
<?xml version='1.0' encoding='UTF-8'?><Error><Code>AuthenticationRequired</Code><Message>Authentication required.</Message></Error>
Can we really use this approach with Google Cloud Storage? Am I doing anything wrong?
Note that I can access the file with oauth access_token when following another approach described on the same page documentation page but I prefer not to make a request to get access_token first before making a request to get the file.