google.auth.exceptions.TransportError: Error calling the IAM signBytes API
Environment details
- OS: Linux
- Python version: 3.9.*
- pip version: 21.*
google-authversion: 2.14.1 & 2.13.0
Steps to reproduce
- Attached the code which can help with the reproducing the issue
` from google import auth from google.auth.transport import requests
def generate_download_signed_url_v4(strg_project, bucket_name, blob_name): # auth_request = requests.Request() credentials, project = auth.default() if credentials.token is None: # Perform a refresh request to populate the access token of the # current credentials. credentials.refresh(requests.Request()) storage_client = storage.Client(project=strg_project) bucket = storage_client.bucket(bucket_name) blob = bucket.blob(blob_name) signed_url = blob.generate_signed_url( version="v4", # This URL is valid for 15 minutes service_account_email=credentials.service_account_email, access_token=credentials.token, expiration=datetime.timedelta(minutes=15), # Allow GET requests using this URL. method="GET", ) print(f"Generated GET signed URL for the Storage Bucket: {bucket_name} Blob:{blob_name}") return signed_url `
Error : google.auth.exceptions.TransportError: Error calling the IAM signBytes API b'{\n "error": {\n "code": 403,\n "message": "The caller does not have permission",\n "status": "PERMISSION_DENIED"\n }\n}\n'
Error: Traceback (most recent call last): File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/functions_framework/init.py", line 99, in view_func return function(request._get_current_object()) File "/workspace/main.py", line 64, in data_load_gcs_to_neo4j data_load_file_signed_url = generate_download_signed_url_v4(strg_project,'dummyfile.csv') File "/workspace/main.py", line 34, in generate_download_signed_url_v4 signed_url = blob.generate_signed_url( File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/cloud/storage/blob.py", line 602, in generate_signed_url return helper( File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/cloud/storage/_signing.py", line 624, in generate_signed_url_v4 signature = _sign_message(string_to_sign, access_token, service_account_email) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/cloud/storage/_signing.py", line 684, in _sign_message raise exceptions.TransportError( google.auth.exceptions.TransportError: Error calling the IAM signBytes API: b'{\n "error": {\n "code": 403,\n "message": "The caller does not have permission",\n "status": "PERMISSION_DENIED"\n }\n}\n'
Issue was with the roles/iam.serviceAccountTokenCreator, provided the role with the access
Issue was with the roles/iam.serviceAccountTokenCreator, provided the role with the access