Created
August 12, 2020 10:18
-
-
Save wescpy/53d38da1e1ee32db91e5b9d8c95315fa to your computer and use it in GitHub Desktop.
"Unit tester" for Google Auth Library (Python) Bug 501
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/googleapis/google-auth-library-python/issues/501 | |
from __future__ import print_function | |
import os | |
from google.oauth2 import credentials | |
TOKENS = 'tokens.json' # OAuth2 token storage | |
if os.path.exists(TOKENS): | |
creds = credentials.Credentials.from_authorized_user_file(TOKENS) | |
if not (creds and creds.valid): | |
if creds and creds.expired and creds.refresh_token: | |
print('** Auto-refresh: got creds? [%s], valid? [%s], expired? [%s]' % ( | |
bool(creds), creds.valid, creds.expired)) | |
else: | |
print('** Re-run flow: creds [%s], valid? [%s], expired [%s]' % ( | |
bool(creds), creds.valid, creds.expired)) | |
else: | |
print('** "Valid" creds: creds [%s], valid? [%s], expired [%s]' % ( | |
bool(creds), creds.valid, creds.expired)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment