Reputation: 1250
I want to reauthenticate my Google Drive Credentials so that I can login from a different Google account and access it using pydrive. How can I do that? I am using the following code to authenticate:
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(auth = gauth)
I want to get a fresh token and option to login again into a different google account?
Thanks for helping!
Upvotes: 3
Views: 3608
Reputation: 1380
I factory reset my runtime and was able to get it to accept a different credential.
Runtime -> factory reset runtime
Upvotes: 0
Reputation: 111
Try deleting the credential file produced by auth.authenticate_user()
based on the auth module
rm /content/adc.json
Upvotes: 3
Reputation: 633
To reset credentials just remove the gdrive config folder with a shell command from a code block
rm ~/.config/Google/DriveFS/ -rf
Upvotes: 1
Reputation: 697
I have just found a solution to this issue. If one goes to his/hers Google Account Settings->Security->Signing in to other sites(all the way down)->YOUR PROCESS NAME and then simply remove it. If you try simply listing the files in the authenticated drive again it should fail with "Token has been expired or revoked."
Just make sure when you create and enter your correct account credentials to delete the credentials/client_secret.json file as the settings.yaml does not seem to overwrite
Upvotes: 1
Reputation: 51
I ran into a similar problem where I clicked on the wrong account for Google Drive authentication. None of the files I needed to access were available, and I couldn't figure out a way to revoke a token by the comments above. I tried both restarting the runtime and changing from GPU to TPU. When I tried the latter, it worked and the authorization prompt returned. However, I'm not sure if it worked or just reached the token refresh time.
Upvotes: 0