Redirect URI does not match initial auth code URI

oauth

#1

When posting from postman to authorize I’m getting the following error
{
“status”: “MISMATCH_REDIRECT_URI_AUTH_CODE”,
“message”: “redirect URI does not match initial auth code URI”,
“correlationId”: “c5571d6c-b0e2-498b-8851-258e534714f2”,
“requestId”: “df44f6cd7accb463bf178f068dca03e3”
}
Steps I have taken: By mistake I have kept the re direct URI as example.com. I got the code and then I tried to post in postman to get the access token. I got the above error.
Then, I’ve tried to start the re-authorization process from start, created a new account and app, to make sure I’m entering the same address (https://www.hubspot.com) however, this still results in the same error


#2

Hi @Basha,

The redirect URI you specify when initiating the Oauth connection must exactly match the redirect URI you included in the request to get access/refresh tokens. Using the example from the docs, if you initiate the connection with this URL:

https://app.hubspot.com/oauth/authorize?client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&scope=contacts%20automation&redirect_uri=https://www.example.com/

You have to include the exact redirect URI in your request to get access/refresh tokens:

https://api.hubapi.com/oauth/v1/token Headers: Content-Type: application/x-www-form-urlencoded;charset=utf-8 Data: grant_type=authorization_code&client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&client_secret=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy&redirect_uri=https://www.example.com/&code=zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz

If you’ve done that and you’re still seeing the error, can you send me the URL you’re using to initiate the connection, as well as the full request you’re sending to get access/refresh tokens (sans code/client secret/etc.)?



#3

Hi, Thanks for the reply.Yes, you are right. The redirect URI you specify when initiating the Oauth connection must exactly match the redirect URI you included in the request to get access/refresh tokens
In my first attempt, I made a mistake by not specifying the exact redirect URI. Then, I I created the code again and passed in the postman to get the access token.This time I am sure that the redirect URI is exactly same. But still I got the error as Redirect URI does not match initial auth code URI.

Today, I created a new account and app then I tried to get the code, But it is throwing me error like "You do not have the correct role to grant these permissions. Please contact your administrator".

Not sure whether I am missing anything here. Please suggest…