0

I connected to my Google Drive using this code

!pip install -U -q PyDrive

from google.colab import files
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

I deleted the adc.json file, and when I run the code block again, it asks me to authenticate again, and use a different Google Drive user. However, when I upload a file, it's still uploading to the old google drive.

I even tried pip uninstalling and reinstalling pydrive, authenticate to new user again, upload file, and it still uploads to the old google drive.

I am wondering why this happens? Since the adc.json file is deleted and the runtime is reset, there should be nothing connecting to the old credentials. Perhaps some sort of bug?

SantoshGupta7
  • 5,607
  • 14
  • 58
  • 116
  • 1
    You may try the menu "reset all runtime" then try again. – korakot Jun 02 '19 at 03:17
  • That would delete the file I am trying to upload unfortunately – SantoshGupta7 Jun 02 '19 at 03:18
  • 1
    another method is to use google.colab.drive.mount(...). It has a separate authentication to auth.authenticate_user() – korakot Jun 02 '19 at 03:21
  • great, it looks like I was able to log into the new account, but now I'm stuck and moving the file to the drive, I tried os.rename , shutil.move , shutil.copy, and shutil.copyfile, they're all giving network error or OSError: [Errno 95] Operation not supported: – SantoshGupta7 Jun 02 '19 at 03:24
  • 1
    You can try `!cp file1 file2` or `!cp -r` for directory. – korakot Jun 02 '19 at 15:49

0 Answers0