I am using Google's google-cloud-storage
Python package for GCS access. When I get a 403 error it could be for many different reasons. Google's SDK by default only provides this message:
('Request failed with status code', 403, 'Expected one of', <HTTPStatus.OK: 200>)")
Using a debugger I can look deeper into the library and find _upload.py
has a _process_response
method where the true HTTP response can be found, with the following message as part of the result:
"message": "$ACCOUNT does not have storage.objects.delete access to $BLOB."
Q: Is there any way I can access this more useful error code or the raw response?
I am hoping to present to the user the difference between e.g. expired credentials and attempting to do something your credentials do not allow.