Search code examples
oauth-2.0tokenaccess-token

Google oAuth2 redirect_uri_mismatch in token access


I am trying to access token from one-time code using Google oAuth2. But I am getting an error message redirect_uri_mismatch in the response. However i've already added the redirect_uri in console.

I have my Authorized redirect uri as:

http://localhost:3020/api/users/google_oauth_store_token

My request:

Request URL = https://www.googleapis.com/oauth2/v3/token?code=xXXXxx&client_id=xxxxxx&client_secret=xxx&redirect_uri=http://localhost:3020/api/users/google_oauth_store_token&grant_type=authorization_code

My response:

  response = {
    "error": "redirect_uri_mismatch",
    "error_description": "Bad Request"
  }

Solution

  • That was my mistake. I had to use the redirect_uri that i had used in one-time redirect uri. Google uses one of the redirect_uri to rest the client origin.