googleapis / google-auth-library-python

Google Auth Python Library
https://googleapis.dev/python/google-auth/latest/
Apache License 2.0
771 stars 304 forks source link

OAuth2 RefreshError while refreshing access token in Docker #1435

Closed Dave-JG closed 8 months ago

Dave-JG commented 8 months ago

Google Sheets and Drive API connections suddenly stopped working two days ago. No code or credentials have changed. OAuth2 token refreshes work fine locally. However, when running within Docker, with access to same credentials file and tokens, I receive the following error.

File "/google_sheets_connect.py", line 32, in creds.refresh(Request()) File "/usr/local/lib/python3.7/site-packages/google/oauth2/credentials.py", line 344, in refresh self._universe_domain google.auth.exceptions.RefreshError: User credential refresh is only supported in the default googleapis.com universe domain, but the current universe domain is None. If you created the credential with an access token, it's likely that the provided token is expired now, please update your code with a valid token.

clundin25 commented 8 months ago

@arithmetic1728 can you take a look?

arithmetic1728 commented 8 months ago

@Dave-JG It seems your user credentials universe_domain is None, the only cause I can think of is here. I created a branch called issue with a potential fix. You can install it with:

pip install git+https://github.com/googleapis/google-auth-library-python.git@issue

Let me know if it works for you. If not, please provide a simple repro to help me identify the issue. Thanks!

Dave-JG commented 8 months ago

Thank you @clundin25 and @arithmetic1728 for the timely response. This resolved the issue.