2
votes

I'm following the Google Developer "Quickstart: Run a Gmail App in Python" https://developers.google.com/gmail/api/quickstart/quickstart-python

All is ok up to step 3 "Run the sample", where the instructions say to "Run the sample using python quickstart.py."

When I do this, the expected result is my browser would load and start the authorization. Instead, I get the Error 400 page on Google.

Error: redirect_uri_mismatch

The redirect URI in the request: http://localhost:8080/ did not match a registered redirect URI

Problem is, "localhost..." is not in redirect URIs, I've checked many other questions similar to this, usually the answers suggest confirming the URL's are EXACTLY the same. I've done that, https/http, additional backslashes, all is identical. Google still says I'm sending localhost:8080.

1
It appears the quickstart.py file Google provides is responsible for the localhost:8080 issue. In the Error 400 page, HTTP contains this URL: accounts.google.com/o/oauth2/… If I change localhost to the redirect URI I added in Developer Console, everything works... What is replacing the redirect URI in my secrets.json file with localhost:8080 ? - thomas.of.april
You must have downloaded the client_secret.json from API console, right? I guess you downloaded the default JSON available. Create a new Client key and select installed application there and then use its JSON. Should work. - gitter

1 Answers

4
votes

The redirect URI specified in the dev console should match what the app is actually redirecting to. Simply use http://localhost:8080/ as your redirect uri in the dev console instead of suffixing it with oauthclient... (which is the default that the dev console provides you).