4

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)

Shahab Ali
  • 389
  • 1
  • 3
  • 23

4 Answers4

13

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.

RobertoC
  • 131
  • 1
  • 4
2

Edit Your URL and replace http://localhost:8080/ by http://localhost:8080

it works for me

Ijaz Ur Rahim
  • 368
  • 4
  • 18
0

You're almost there. Just add '/oauth2callback' as indicated in the greyed texts.

So, under 'Authorized redirect URIs' :

http://localhost:8080/oauth2callback
ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
0

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?

Edo Edo
  • 164
  • 2
  • 9