I followed this Gmail API Python Quickstart tutorial: https://developers.google.com/gmail/api/quickstart/python
I configured my OAuth client ID in the API console as instructed (see the first image below). However, launching the script opens a browser session that results in the 400 error below.
The redirect URL matches what is registered in the API console.
HOWEVER, the quickstart script opens the following URL: https://accounts.google.com/o/oauth2... &redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F ...
Manually changing redirect URI to http://localhost:8080 partially fixes the problem as I proceed to the authorization request, but then the response can't get returned to the command prompt.
How can I force the quickstart program to produce a URL that leaves the redirect URI as http://localhost:8080?
The cause of the error you're getting is that the Python Quickstart says:
d. Select the Credentials tab, click the Create credentials button and select OAuth client ID.
e. Select the application type Other, enter the name "Gmail API Quickstart", and click the Create button.
However, looking at what you're doing, you are using Web Application instead of Other.
When I used the Other as client_secret.json, I didn't encounter this problem.
result:
The authentication flow has completed.
No hacks/workaround needed. Just follow instructions :)