I'm writing a function that logs in a user to their Google Drive using OAuth 2.0. It returns the authenticated drive
object. Here's my code:
def login_with_account():
gauth = GoogleAuth()
if 'credentials.json' in os.listdir():
gauth.LoadCredentialsFile("credentials.json")
if gauth.access_token_expired:
gauth.Refresh()
else:
gauth.Authorize()
else:
gauth.LocalWebserverAuth()
gauth.SaveCredentialsFile("credentials.json")
drive = GoogleDrive(gauth)
return drive
My question is: Do I need to Authorize()
after Refresh()
as well or is this enough? documentation link to Refresh()
, can't find anything specific in the docs https://docs.iterative.ai/PyDrive2/pydrive2/#pydrive2.auth.GoogleAuth.Refresh
source https://stackoverflow.com/questions/76600330/pydrive2-is-authorize-needed-after-refresh
Comments
Post a Comment