0

Program:

import googleapiclient, oauth2client
import httplib2
import pprint

from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
from oauth2client.client import OAuth2WebServerFlow

client_id = ##blah blah
secret = ## blah blah

oauth_scope = 'https://www.googleapis.com/auth/drive'

flow = OAuth2WebServerFlow(client_id, secret, oauth_scope)
authorize_url = flow.step1_get_authorize_url()
print('Go to the following link in your browser: '+ authorize_url)
code = raw_input('Enter verificaiton code: ').strip()
credentials = flow.step2_exchange(code)

Error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-15-f4e9728695d1> in <module>()
     14 
     15 flow = OAuth2WebServerFlow(client_id, secret, oauth_scope)
---> 16 authorize_url = flow.step1_get_authorize_url()
     17 print('Go to the following link in your browser: '+ authorize_url)
     18 code = raw_input('Enter verificaiton code: ').strip()

1 frames
/usr/local/lib/python3.6/dist-packages/oauth2client/client.py in step1_get_authorize_url(self, redirect_uri, state)
   1920 
   1921         if self.redirect_uri is None:
-> 1922             raise ValueError('The value of redirect_uri must not be None.')
   1923 
   1924         query_params = {

ValueError: The value of redirect_uri must not be None.

Hopefully this is the right place to ask this. I am trying to use the Google Drive API to access the metadata of all the photos in a folder on my Drive via a project in Google Colab. I am pretty new to APIs and networking in general so I don't really know what I'm doing. I tried to set up the credentials thing on the Google APIs admin site, following this video {https://www.youtube.com/watch?v=zJVCKvXtHtE}. I successfully got a client key and a secret key and added it where I crossed stuff out in the image provided below. I get this error when compiling -- I'm not really sure what it means/how to fix it? I don't know anything about the OAuth2Client library or how the networking stuff works, but all the importing compiles, so I know all the libraries are installed correctly. I'm guessing I didn't set up the credentials correctly. Any tips?

Picture of Code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.