Trouble Installing Developer App - Bad Auth Code


#1

Hi all,

I’m trying to install my developer application into my company’s Hubspot portal, I’m near the end of the process to complete the OAUTH flow however I’m having an issue that is preventing me from getting the access token. I’m using Postman to construct the request and I keep receiving this response:

{“status”:“BAD_AUTH_CODE”,“message”:“missing or unknown auth code”,“correlationId”:“4c05bb8b-5a2f-4646-bc18-074356cdc252”,“requestId”:“d4f849d1ab68c703ee9e7d690abecd90”}

The request is being made to: https://api.hubapi.com/oauth/v1/token

The client secret/ID are correct and I’m using the correct code received after visiting the link below and being redirected to the home page. (Client ID hidden on purpose… don’t know if I should do that or not).

https://app.hubspot.com/oauth/2675739/authorize?client_id=xxx&scope=contacts%20automation&redirect_uri=https%3A%2F%2Fwww.hubspot.com

Is there a step I’m missing somewhere?

Thanks for the help!


#2

@KodyWright How are you formatting the call? Maybe you are not passing in the code correctly? Can I see an example of your call in postman?


#3

Sure thing, here’s the full code being sent.

POST /oauth/v1/token HTTP/1.1
Host: api.hubapi.com
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Postman-Token: 5c0ec2bf-36c5-ded0-9998-16da75a46361

grant_type=authorization_code&client_id=xxx&client_secret=xxx&redirect_uri=https%3A%2F%2Fwww.hubspot.com%2F%3Fcode%xxx


#4

If you need I can paste the info with ID, secret and code. Not sure what all I should hide on these forums.


#5

@KodyWright Nothing jumps out at me looking at that. Are you doing the second call right after the first? As the code can expire. About half way down this forum I share photos of what it looks like in postman to make the call.


#6

Odd, but I switched from sending data in raw format to form-url-encoded (like the image you attached) and it worked perfectly. Thanks for the help! I really appreciate it.


#7

@pmanca What is included in the header in “Postman” because when i run my app its again giving BAD_AUTH_CODE error you have included the correct part in body section but the two statements given in the header was not shown kindly share that in a same way e.g Image. Thanks


#8

@Umar_Jamil The link above has images to both the body and the headers. If you are having any trouble still, please start a new thread.


#10

@pmanca Kindly include the image of header as well. The body section is fine but its producing the same error.


#11

@Umar_Jamil The headers are in an image posted in the link above. Please review the other thread.


#12

@pmanca See the output with the same header and body as you told.


#13

@pmanca Thanks for the help! I really appreciate it. its work for me.


#14

@Umar_Jamil i’m glad you got it working. Let us know if you run into anything else.


#15

how could you share the code please