Reputation: 692
I am trying to set up a Google Drive API instance with Python to download files. I set up an OAuth 2.0 Client ID on my Google APIs Console for a specific project and have enabled the Google Drive API client. However, I keep getting a redirect_uri_mismatch error when testing on localhost. I read somewhere to include http://localhost:8080 as the redirect URI for testing, however, the redirect_uri_mismatch error keeps throwing the error on a random port on localhost. I am not sure how to set up a correct port for localhost so this error doesn't keep getting thrown. It currently says that the redirect URI the instance is trying to use is http://localhost:49334/. If I add that URI to my credentials.json file, then it just throws another mismatch error over a different port. How do I fix this issue? I am exactly using code from this documentation: https://developers.google.com/drive/api/v3/quickstart/python and https://developers.google.com/drive/api/v3/manage-downloads.
Upvotes: 1
Views: 3195
Reputation: 201593
Please modify as follows.
Please set the redirect uri at "Google APIs Console's credentials section" of Google Cloud Platform as follows. When you modified it, please save it. And please confirm whether the redirect url was modified.
From
http://localhost:8080
To
http://localhost:8080/
Please modify your script as follows. From your replying, I understand that you are using the script of Quickstart for python.
From
creds = flow.run_local_server(port=0)
To
creds = flow.run_local_server(port=8080)
Run the script and authorize.
Upvotes: 6