Colabtools: Failure("Unexpected error response: {\n \"error\" : \"invalid_grant\",\n \"error_description\" : \"Malformed auth code.\"\n}")

Created on 20 Aug 2018  路  5Comments  路  Source: googlecolab/colabtools

I am trying to access my google drive from Google Colab. I am following this tutorial: https://colab.research.google.com/drive/1srw_HFWQ2SMgmWIawucXfusGzrj1_U0q#scrollTo=5Jk9jZm8mhFX

The following cell generates error:

# Generate creds for the Drive FUSE library.
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
# Work around misordering of STREAM and STDIN in Jupyter.
# https://github.com/jupyter/notebook/issues/3159
prompt = !google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass(prompt[0] + '\n\nEnter verification code: ')
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}

Error message:

Please, open the following URL in a web browser: https://accounts.google.com/o/oauth2/auth?client_id=32555940559.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&response_type=code&access_type=offline&approval_prompt=force
Please enter the verification code: Cannot retrieve auth tokens.
Failure("Unexpected error response: {\n  \"error\" : \"invalid_grant\",\n  \"error_description\" : \"Malformed auth code.\"\n}")
Please, open the following URL in a web browser: https://accounts.google.com/o/oauth2/auth?client_id=32555940559.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&response_type=code&access_type=offline&approval_prompt=force

Enter verification code: 路路路路路路路路路路


Any fix?

Most helpful comment

This issue is the result of a recent feature change. An immediate work-around is to run the following code snippet:

import os
os.environ['USE_NATIVE_IPYTHON_SYSTEM_COMMANDS'] = '1'

Then, repeat the problematic execution.

Separately, we're working on rolling back the offending change for all users.

All 5 comments

I've started having this exact same issue when trying to FUSE with google drive! Started having it this morning (with exact same code has been successful the past few months). Fails with both your method and the alessandro-strada FUSE.

Thanks for the reports. We're looking into this now and will keep this issue updated.

This issue is the result of a recent feature change. An immediate work-around is to run the following code snippet:

import os
os.environ['USE_NATIVE_IPYTHON_SYSTEM_COMMANDS'] = '1'

Then, repeat the problematic execution.

Separately, we're working on rolling back the offending change for all users.

All backends should include the rollback fix. Please reopen if this issue recurs.

The code above now results in:

IndexError                                Traceback (most recent call last)
<ipython-input-5-d5209fdfbc76> in <module>()
     13 # https://github.com/jupyter/notebook/issues/3159
     14 prompt = get_ipython().getoutput('google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL')
---> 15 vcode = getpass.getpass(prompt[0] + '\n\nEnter verification code: ')
     16 get_ipython().system('echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}')
     17 

IndexError: list index out of range
Was this page helpful?
0 / 5 - 0 ratings