Reputation: 41
When I see this tutorial and try to run the test code Google Drive SDK Python Quickstart Sample
Video: https://www.youtube.com/watch?v=zJVCKvXtHtE&list=PL0FA2818902D9D123
Code: https://docs.google.com/document/d/1GD3Ee07QsqxQZ-UDTNIbMqtSu4U_servCeQsd9rCkp8/edit
I got an error, it is saying "ValueError: The value of redirect_uri must not be None"
I googled, can't fix this problem. What should I fix?
Thank you!!!
Upvotes: 3
Views: 1306
Reputation: 2006
I had the same problem. The solution for me was add redirect_uri="urn:ietf:wg:oauth:2.0:oob" in the code.
#Before
flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE)
#After
flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, redirect_uri="urn:ietf:wg:oauth:2.0:oob")
Upvotes: 2
Reputation: 115
The problem is really simple actually.The api just needs to know what to do with the credential.You see a installed application and a web application handles it differently.For a web application, authorising would redirect the user to another page. For a installed application, you might want to be provided with a key.
So if you are using a installed application, change the following lines of code.
from oauth2client.client import flow_from_clientsecrets
path_to_json="client_secrets.json" # download from https://code.google.com/apis/console/
AUTH_SCOPE 'https://www.googleapis.com/auth/drive'
#redirect_uri also provided in api console.The other URI mentioned there is for web applications.
flow = flow_from_clientsecrets(Path_to_JSON,AUTH_SCOPE,redirect_uri="urn:ietf:wg:oauth:2.0:oob")
`
Upvotes: 4