Reputation: 3471
I am Creating and Authorizing an OAuth Token according to this webpage: https://code.google.com/p/google-mail-oauth2-tools/wiki/OAuth2DotPyRunThrough
But I got this error: redirect_uri_mismatch.
The redirect URI in the request: urn:ietf:wg:oauth:2.0:oob did not match a registered redirect URI
from_login=1
cookie_policy_enforce=false
scope=https://mail.google.com/
response_type=code
access_type=online
redirect_uri=urn:ietf:wg:oauth:2.0:oob
as=-80019291b2cb8ed
display=page
pli=1
client_id=......
authuser=0
hl=en
I thought this might be helpful: Google OAuth 2 authorization - Error: redirect_uri_mismatch
But when I try to register the redirect url to my console, I was told that the url is invalid.
Upvotes: 24
Views: 54221
Reputation: 359
redirect_uri must be an EXACT MATCH on the developers console.
In my case, this was due to a trailing slash( / ).
In the Google Cloud console, I had http://localhost:8080
under the redirect URIs in the list while my code was sending http://localhost:8080/
while making the oAuth call.
Upvotes: 0
Reputation: 8541
The easiest way is to create the service account.
Create the document using your own account and share it with the service account.
Upvotes: 0
Reputation: 7500
I was getting this error, because I was incorrectly following the steps for installed application flow here
https://github.com/googleads/googleads-python-lib/wiki
instead of the server to server flow.
Upvotes: 0
Reputation: 461
For my native app, I tried dozens of different things. I finally got it to work by using "redirect_uri=http%3A%2F%2Flocalhost%3A1234" where 1234 is the port number. This has to be identical in the two requests (authorization code and the access token). Notice the use of percent encoding.
Upvotes: 0
Reputation: 2820
In my case, instead of creating web app, i just chose Other in: OAuth Client ID > Other
and thats it.
Upvotes: 3
Reputation: 51
Lost 4 or 5 hours with this... use 'postmessage' as parameter value, not the real Redirect Uri...
$client->setRedirectUri('postmessage');
Upvotes: 5
Reputation: 9554
2015July15 - working signin started causing Error 400 with Error: redirect_uri_mismatch
i posted a solution on a similar SO QUESTION: changed loading script to
<script src="https://apis.google.com/js/client:platform.js?onload=startApp></script>
Upvotes: 1
Reputation: 131
Please note that the 'redirect_uri' value of the Token request need to be the same as the 'redirect_uri' value of the Authorization request.
Upvotes: 7
Reputation: 1339
For my web application i corrected my mistake by writing
instead of : http://localhost:11472/authorize/
type : http://localhost/authorize/
Upvotes: 10
Reputation: 2437
For anybody that is still stumped with this problem, you must have the 'Platform' set to 'Native (Windows Mobile, Blackberry, desktop, devices, and more)' when registering your app in the Google Cloud Console, otherwise, it will not let you use 'urn:ietf:wg:oauth:2.0:oob' as the redirect URI.
Upvotes: 3
Reputation: 11878
Just in case if you're using Google+ javascript button (with web application), you have to put postmessage
instead of actual URI. It takes me almost whole day to figure out this, because Google docs doesn't clearly stand it for some reason.
Upvotes: 32
Reputation: 1240
When you register your app at https://code.google.com/apis/console
and
make a Client ID, you get a chance to specify one or more redirect
URIs. The value of the redirect_uri
parameter on your auth URI has to
match one of them exactly.
Upvotes: 7
Reputation: 1206
The redirect_uri (urn:ietf:wg:oauth:2.0:oob) is only applicable to those Google client ids that have been generated for installed applications. You can go to your console and create a new client id of this type.
Upvotes: 50