'MISMATCH_REDIRECT_URI_AUTH_CODE' - redirect URI does not match initial auth code URI

I am trying to get the access token and refresh token for my test app but I am getting - “‘MISMATCH_REDIRECT_URI_AUTH_CODE’ - redirect URI does not match initial auth code URI”.

This the code I am using to make the request:

full_URL = ‘https://app.hubspot.com/oauth/authorize?client_id=CLIENTID&redirect_uri=https://hubspot.com&scope=contacts%20content%20automation%20oauth

REDIRECT_URI = ‘https://www.hubspot.com/

token_url = ‘https://api.hubapi.com/oauth/v1/token
headers = {‘content-type’: ‘application/x-www-form-urlencoded’,
‘accept’: ‘application/json’}
form = {‘grant_type’:‘authorization_code’,
‘client_id’:CLIENT_ID,
‘client_secret’: CLIENT_SECRET,
‘redirect_uri’:REDIRECT_URI,
‘code’:authorisation_code}

I am using the correct Redirect URI (https://www.hubspot.com/) still getting this error, I can’t figure out what’s the reason for this error.

@ShaanBisht

Is this issue still happening?

@himanshurauthan , any thoughts?

Thank you @dennisedson,

Hello @ShaanBisht,

The code is looking fine just header is not correct according to me, so please use headers = {‘Content-Type: application/x-www-form-urlencoded;charset=utf-8’}

Hopefully, it will work.

Regards,

Hi @ShaanBisht ,

You have to add your landing page “redirect url”, where you want to get response of app authorization.
Example of App Redirect URL in screen shot : Screenshot by Lightshot

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.