Reputation: 399
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
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)
Upvotes: 4
Views: 2567
Reputation: 131
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.
Upvotes: 13
Reputation: 164
It seems that google api has changed their policies on authorized domains, i heard there's remote domain that redirect to localhost? or you can change your hosts file... it doesnt make sense, because google supports api usage on native apps, why would they need a domain name?
Upvotes: 0
Reputation: 410
Edit Your URL and replace http://localhost:8080/
by http://localhost:8080
it works for me
Upvotes: 2
Reputation: 17613
You're almost there. Just add '/oauth2callback' as indicated in the greyed texts.
So, under 'Authorized redirect URIs' :
http://localhost:8080/oauth2callback
Upvotes: 0