Created
June 13, 2019 12:53
-
-
Save whatnick/666e03d25286852235750d269ed0eda8 to your computer and use it in GitHub Desktop.
Integration between PyDrive and Flask-Dance
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
oauth_token = session['google_oauth_token'] | |
from oauth2client.client import OAuth2Credentials | |
from datetime import datetime | |
expirty_str = str(datetime.fromtimestamp(oauth_token['expires_at'])) | |
with flask_app.app_context(): | |
token_data = { | |
'access_token' : oauth_token['access_token'], | |
'token_expiry' : expirty_str, | |
'user_agent' : 'PyDrive Automation', | |
'refresh_token' : None, | |
'invalid' : False, | |
'client_id' : flask_app.config['GOOGLE_OAUTH_CLIENT_ID'], | |
'client_secret': flask_app.config['GOOGLE_OAUTH_CLIENT_SECRET'], | |
'redirect_uris': [redir_url], | |
'auth_uri': 'https://accounts.google.com/o/oauth2/auth', | |
'token_uri': 'https://accounts.google.com/o/oauth2/token' | |
} | |
gauth.credentials = OAuth2Credentials.from_json(json.dumps(token_data)) | |
logging.info("PyDrive is now authenticated") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment