-
Notifications
You must be signed in to change notification settings - Fork 325
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
from_user_info
currently always sets the token to None. So a credential created from a JSON is always invalid and must be refreshed.
>>> from google.oauth2 import credentials
>>> TOKENS = 'tokens.json' # OAuth2 token storage
>>> creds = credentials.Credentials.from_authorized_user_file(TOKENS)
>>> creds.valid
False
>>> creds.expiry
>>> creds.expired
False
google-auth-library-python/google/oauth2/credentials.py
Lines 235 to 244 in 772dac6
return cls( | |
None, # No access token, must be refreshed. | |
refresh_token=info["refresh_token"], | |
token_uri=_GOOGLE_OAUTH2_TOKEN_ENDPOINT, | |
scopes=scopes, | |
client_id=info["client_id"], | |
client_secret=info["client_secret"], | |
quota_project_id=info.get( | |
"quota_project_id" | |
), # quota project may not exist |
If a token is available, from_user_info
should use it. info.get('token', None)
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.