Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google OAuth 2.0 redirect_uri_mismatch error

  1. I created a Google OAuth 2.0 ClientID and secret in Google Developer console

  2. After that I tested in Google OAuth playground (https://developers.google.com/oauthplayground). and registered ClientID and secret already created above and applied to Google OAuth 2.0 playground setting menu.

  3. Some people say that after creating ClientID/secret they need some time for testing. So after two days I tried to test in the same conditions but the error is same redirect_uri_mismatch.

How can I solve this?

like image 421
sysmoon Avatar asked Jan 20 '14 01:01

sysmoon


People also ask

How do I fix OAuth error?

When a user tries to login after the session id is expired, the system throws the OAuth error. Solution: Typically, clearing the browser or device cache fixes the problem.

What is redirect URI in oauth2?

A redirect URI, or reply URL, is the location where the authorization server sends the user once the app has been successfully authorized and granted an authorization code or access token.


2 Answers

As little as having a '/' at the end of your uri and not having the same '/' at the end in your code will throw it off.

like image 173
RAW Avatar answered Oct 24 '22 20:10

RAW


Your site URL and the Authorized redirect URIs in developer console should be the exact match.

This kind of error occurs if one URL has www (http://www.example.com) and the other URL is non-www (http://example.com).

Other common URI mismatch are:

  • Using http:// in Authorized Redirect URIs and https:// as actual URL, or vice-versa
  • Using trailing slash (http://example.com/) in Authorized Redirect URIs and not using trailing slash (http://example.com) as actual URL, or vice-versa

Here is the step-by-step procedure (with screenshots) to update the Authorized redirect URIs in Google Developer Console (For those like me who found it difficult to get to that page).

  1. Go to https://console.developers.google.com

  2. Select your Project

Select your Project

  1. Click on the menu icon

Click on the menu icon

  1. Click on API Manager menu

Select API Manager menu

  1. Click on Credentials menu. And under OAuth 2.0 Client IDs, you will find your client name. In my case, it is Web Client 1. Click on it and a popup will appear where you can edit Authorized Javascript Origin and Authorized redirect URIs.

Select Credentials menu

Here is a Google article on creating project and client ID.

like image 26
Mukesh Chapagain Avatar answered Oct 24 '22 20:10

Mukesh Chapagain