Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: redirect_uri_mismatch pydrive

I am trying to connect to google drive and for that I am using python pydrive library. I have followed the documentation and written a snippet for connecting with google drive. But I get an error Error: redirect_uri_mismatch

The redirect URI in the request, http://localhost:8080/, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs

Here is the code of pydrive that I have executed (I have installed the pydrive library as well)

from pydrive.auth import GoogleAuth

gauth = GoogleAuth()
gauth.LocalWebserverAuth()

I am posting an image of my console.developer account, you can see I have written the address correctly as specified by the pydrive documentation. I have also added outcallback in the url but I am still getting the same error. Any help will be appreciated. Thanks Console.developers account

Added outhcallback

This is my client_secrets.json file content:

{"web":{,"project_id":"my-project-1532814702018","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","redirect_uris":["http://localhost:8080/oauth2callback"],"javascript_origins":["http://localhost","http://localhost:8080"]}}

(I have removed client id and client secret here)

like image 895
Shahab Ali Avatar asked Jan 03 '23 02:01

Shahab Ali


1 Answers

I know its a bit late now, but it may help someone who encounters this issue. For me it was really silly. In "Authorized redirect URIs" field it must be "http://localhost:8080/" with a slash at end. In "Authorized JavaScript origins" it must be "http://localhost:8080" without a slash.

like image 115
RobertoC Avatar answered Feb 06 '23 19:02

RobertoC