# 'MISMATCH\_REDIRECT\_URI\_AUTH\_CODE' - redirect URI does not match initial auth code URI

**URL:** <https://community.hubspot.com/t/mismatch-redirect-uri-auth-code-redirect-uri-does-not-match-initial-auth-code-uri/40438>\
**Category:** APIs & Integrations\
**Tags:** python, developer-tools, oauth\
**Created:** [July 9, 2021, 11:24am UTC](https://community.hubspot.com/t/mismatch-redirect-uri-auth-code-redirect-uri-does-not-match-initial-auth-code-uri/40438 "2021-07-09T11:24:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShaanBisht](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/shaanbisht/32/75413_2.png) [@ShaanBisht](https://community.hubspot.com/u/ShaanBisht)\
**Post date:** [July 9, 2021, 11:24am UTC](https://community.hubspot.com/t/mismatch-redirect-uri-auth-code-redirect-uri-does-not-match-initial-auth-code-uri/40438/1 "2021-07-09T11:24:20Z")

</div>

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](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/](https://www.hubspot.com/)’

token\_url = ‘[https://api.hubapi.com/oauth/v1/token](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/](https://www.hubspot.com/)) still getting this error, I can’t figure out what’s the reason for this error.

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [July 12, 2021, 3:53pm UTC](https://community.hubspot.com/t/mismatch-redirect-uri-auth-code-redirect-uri-does-not-match-initial-auth-code-uri/40438/2 "2021-07-12T15:53:18Z")

</div>

@ShaanBisht

Is this issue still happening?

@himanshurauthan , any thoughts?

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [July 14, 2021, 2:17pm UTC](https://community.hubspot.com/t/mismatch-redirect-uri-auth-code-redirect-uri-does-not-match-initial-auth-code-uri/40438/3 "2021-07-14T14:17:37Z")

</div>

Hi everyone! 👋

Just adding a quick clarification for anyone coming across this thread.

Looking at the original code, the issue appears to be a **mismatch between the redirect URIs** :

- Authorization request: `https://hubspot.com`

- Token request: `https://www.hubspot.com/`

These URLs are different, which explains the `MISMATCH_REDIRECT_URI_AUTH_CODE` error.

To resolve this, make sure you’re using the **same redirect URI in both requests** , and that it’s configured in your app’s OAuth settings.

One additional update: HubSpot now recommends using the OAuth v3 token endpoint (`POST /oauth/v3/token`) for new integrations.

You can find more details in the HubSpot OAuth documentation: [Working with OAuth - HubSpot docs](https://developers.hubspot.com/docs/apps/legacy-apps/authentication/working-with-oauth)

Hope this helps!

* * *

Thank you @dennisedson,

Hello @ShaanBisht,

The main issue is the redirect URI mismatch. Your authorization request uses `https://hubspot.com`, while your token request uses `https://www.hubspot.com/`. Both requests must use the same redirect URI.

Hopefully, it will work.

Regards,

_Moderator Note: this post was reviewed for relevancy and optimized for clarity on October 23, 2026. Thank you for your contributions to the HubSpot Community!_

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [July 13, 2021, 10:49am UTC](https://community.hubspot.com/t/mismatch-redirect-uri-auth-code-redirect-uri-does-not-match-initial-auth-code-uri/40438/4 "2021-07-13T10:49:53Z")

</div>

Hi @ShaanBisht ,

Configure your app’s callback URL in its OAuth settings and ensure the same URL is used in both the authorization and token requests.

Example of App Redirect URL in screen shot : [Screenshot by Lightshot](https://prnt.sc/1aqx67a)

Hope this helps!

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

_Moderator Note: this post was reviewed for relevancy and optimized for clarity on October 23, 2026. Thank you for your contributions to the HubSpot Community!_
