Stack Overflow Asked by Nachengue on January 12, 2021
I had been working on Colab using:
from google.colab import drive
.mount('/content/gdrive')
with no problems, until today.
I don’t know why this error was raised:
Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly&response_type=code
Enter your authorization code:
··········
---------------------------------------------------------------------------
TIMEOUT Traceback (most recent call last)
<ipython-input-4-d05fe204dd76> in <module>()
1 from google.colab import drive
----> 2 drive.mount('/content/gdrive')
4 frames
/usr/local/lib/python3.6/dist-packages/google/colab/drive.py in mount(mountpoint, force_remount, timeout_ms, use_metadata_server)
223 oauth_prompt,
224 problem_and_stopped,
--> 225 drive_exited,
226 ])
227 if case == 0:
/usr/local/lib/python3.6/dist-packages/pexpect/spawnbase.py in expect(self, pattern, timeout, searchwindowsize, async_, **kw)
342 compiled_pattern_list = self.compile_pattern_list(pattern)
343 return self.expect_list(compiled_pattern_list,
--> 344 timeout, searchwindowsize, async_)
345
346 def expect_list(self, pattern_list, timeout=-1, searchwindowsize=-1,
/usr/local/lib/python3.6/dist-packages/pexpect/spawnbase.py in expect_list(self, pattern_list, timeout, searchwindowsize, async_, **kw)
370 return expect_async(exp, timeout)
371 else:
--> 372 return exp.expect_loop(timeout)
373
374 def expect_exact(self, pattern_list, timeout=-1, searchwindowsize=-1,
/usr/local/lib/python3.6/dist-packages/pexpect/expect.py in expect_loop(self, timeout)
179 return self.eof(e)
180 except TIMEOUT as e:
--> 181 return self.timeout(e)
182 except:
183 self.errored()
/usr/local/lib/python3.6/dist-packages/pexpect/expect.py in timeout(self, err)
142 exc = TIMEOUT(msg)
143 exc.__cause__ = None # in Python 3.x we can use "raise exc from None"
--> 144 raise exc
145
146 def errored(self):
TIMEOUT: <pexpect.popen_spawn.PopenSpawn object at 0x7f58fb7ab4e0>
searcher: searcher_re:
0: re.compile('google.colab.drive MOUNTED')
1: re.compile('root@e7a376888b95-b97a84955c154714b7850ceb4ecf0e8e: ')
2: re.compile('(Go to this URL in a browser: https://.*)$')
3: re.compile('Drive File Stream encountered a problem and has stopped')
4: re.compile('drive EXITED')
<pexpect.popen_spawn.PopenSpawn object at 0x7f58fb7ab4e0>
searcher: searcher_re:
0: re.compile('google.colab.drive MOUNTED')
1: re.compile('root@e7a376888b95-b97a84955c154714b7850ceb4ecf0e8e: ')
2: re.compile('(Go to this URL in a browser: https://.*)$')
3: re.compile('Drive File Stream encountered a problem and has stopped')
4: re.compile('drive EXITED')
As everyone knows, this code opens a new tab where you have to select a Google account, click on the ‘Allow’ button, and copy a long password to Colab
EDIT:
I tried to do the same in another way with:
#Installing PyDrive
!pip install PyDrive
#Importing modules
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
#Authenticating and creating the PyDrive client
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
#Getting the file
downloaded2 = drive.CreateFile({'id':"1QGtoo1wqCP2yrjl8kFu4kTfjWqh3EOdt"}) # replace the id with id of file you want to access
downloaded2.GetContentFile('estructura_cc_felipe.xlsx')
But it raises this error:
Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?client_id=32555940559.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&code_challenge=WkM1RS8Flu1_txc3jn4V_FfutgZuRaHSzYbDvs134PM&code_challenge_method=S256&access_type=offline&response_type=code&prompt=select_account
Enter verification code: ··········
---------------------------------------------------------------------------
AuthorizationError Traceback (most recent call last)
<ipython-input-2-bb96e063f8ef> in <module>()
6
7 #Authenticating and creating the PyDrive client
----> 8 auth.authenticate_user()
9 gauth = GoogleAuth()
10 gauth.credentials = GoogleCredentials.get_application_default()
1 frames
/usr/local/lib/python3.6/dist-packages/google/colab/auth.py in authenticate_user(clear_output)
147 context_manager = _output.temporary if clear_output else _noop
148 with context_manager():
--> 149 _gcloud_login()
150 _install_adc()
151 colab_tpu_addr = _os.environ.get('COLAB_TPU_ADDR', '')
/usr/local/lib/python3.6/dist-packages/google/colab/auth.py in _gcloud_login()
97 _os.remove(name)
98 if gcloud_process.returncode:
---> 99 raise _errors.AuthorizationError('Error fetching credentials')
100
101
AuthorizationError: Error fetching credentials
Does anyone know what is wrong? I have been working for a long time importing files located on my Google drive and never had these problems.
It turns out that if you manually copy the auth code from the auth button instead of clicking the copy button, it works
Correct answer by kandi on January 12, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP