google-auth-library-python: Getting "Invalid JWT Signature" after upgrading to rsa==4.7
Environment details
- OS: Linux, Mac
- Python version: 3.7, 3.8
- pip version: 20.3.3
google-auth
version: 1.22.1
Steps to reproduce
We found this bug while using dvc and using Google Cloud Storage as a backend. Authentication with google is done via a service key file. When running dvc with rsa==4.6
everything works fine, but when upgrading to rsa==4.7
, we encounter the following error:
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/dvc/tree/gs.py", line 139, in isfile
return blob.exists()
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 484, in exists
_target_object=None,
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/google/cloud/_http.py", line 431, in api_request
timeout=timeout,
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/google/cloud/_http.py", line 289, in _make_request
method, url, headers, data, target_object, timeout=timeout
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/google/cloud/_http.py", line 327, in _do_request
url=url, method=method, headers=headers, data=data, timeout=timeout
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/google/auth/transport/requests.py", line 460, in request
self.credentials.before_request(auth_request, method, url, request_headers)
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/google/auth/credentials.py", line 133, in before_request
self.refresh(request)
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/google/oauth2/service_account.py", line 361, in refresh
access_token, expiry, _ = _client.jwt_grant(request, self._token_uri, assertion)
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/google/oauth2/_client.py", line 153, in jwt_grant
response_data = _token_endpoint_request(request, token_uri, body)
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/google/oauth2/_client.py", line 124, in _token_endpoint_request
_handle_error_response(response_body)
File "/home/alvaro/.virtualenvs/myenv/lib/python3.7/site-packages/google/oauth2/_client.py", line 60, in _handle_error_response
raise exceptions.RefreshError(error_details, response_body)
google.auth.exceptions.RefreshError: ('invalid_grant: Invalid JWT Signature.', '{"error":"invalid_grant","error_description":"Invalid JWT Signature."}')
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 18 (9 by maintainers)
Commits related to this issue
- chore: bump rsa to working 4.7.2 (the auth bug should be fixed) See: https://github.com/googleapis/google-auth-library-python/issues/667#issuecomment-785142603 — committed to seung-lab/cloud-files by william-silversmith 3 years ago
Thanks for collaborating on this, people! 🥳 🎈
Hi @busunkim96 , after installing
cryptography
and removingrsa
, I get a new error when running the same code in our work project:Some context -
waluigi
is our vendored wrapper around Luigi. We’re usingluigi.contrib.gcs
’sput_multiple()
to upload multiple files in parallel to GCS.It looks like the
_cffi_backend.FFI
objects are from https://github.com/cffi/cffi which is required bycryptography
:Hope that’s helpful.
I’m the author of the RSA package. As you can see in sybrenstuvel/python-rsa#173, there is a problem where attributes on the key objects are missing:
Is Google Auth creating the keys in some non-standard way? The
self.blindfac
attribute is set in the key’s__init__()
function, so I don’t see how it could be missing.Hi,
Thanks for the report! I’ve marked this as external for now since I see you also opened https://github.com/sybrenstuvel/python-rsa/issues/173. Please let me know if something needs to be fixed in this library.