Skip to content

from_authorized_user_file always returns invalid credentials #501

@busunkim96

Description

@busunkim96

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

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.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy