PyDrive icon indicating copy to clipboard operation
PyDrive copied to clipboard

Support using existing access tokens

Open whatnick opened this issue 6 years ago • 2 comments

I am using PyDrive with Flask-Dance , I would like to use the live access token stored in the Flask session by Flask dance with PyDrive, is there any way to short cut the very well meaning auth object and directly give it the access token to use with the rest of the PyDrive calls ?

whatnick avatar Jun 12 '19 19:06 whatnick

Very similar to #10 would appreciate a concrete sample in the docs, specifically for Flask-Dance.

whatnick avatar Jun 13 '19 10:06 whatnick

Here is my solution for posterity:

  • Obtain the auth info stored in the session by Flask-Dance oauth_token = session['google_oauth_token']
  • Create credentials from flask context and session with right amount of dict->json->dict HACK

All this is capture in this gist

Please follow up with any more elegant solution that comes to mind. P.S. Flask Dance scope need to be expanded to include whichever Drive scopes that the application uses.

whatnick avatar Jun 13 '19 12:06 whatnick