Access token return 500 Internal Server Error

New Contributor

When connecting to a certain HubSpot account, after getting the authorization code, the get access token fails with 500 Internal Server Error.

{"status":"error","message":"internal error","correlationId":"22fc323d-85b7-429c-a15a-2bb4d58bdaeb","requestId":"ff01a1df8ca91be60b250d9450afc1a4"}

Our app id: 28750

Can you please take a look and let us know why it is failing?

Reply
0 Upvotes
8 Replies 8
HubSpot Employee

Hi @KingswaySoft  - 

 

To help out here, can you give a bit more detail about the steps of the process? Specifically, if you're at the stage of swapping the code for an access token, can you provide the following:

  • full URL of HTTP request
  • Method
  • Headers
  • body (be sure to redact your `client_secret`)

Less necessary, but you can provide your code snippet too.

Reply
0 Upvotes
New Contributor

Hi @robertainslie , thank you for getting back to us.

Please find the request below:

 

POST https://api.hubapi.com/oauth/v1/token HTTP/1.1
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Host: api.hubapi.com
Content-Length: 220
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

 

grant_type=authorization_code&client_id=551f82b2-2fe6-11e5-9def-3ff296bb2e59&client_secret=555555&redirect_uri=https%3a%2f%2fwww.kingswaysoft.com%2f&code=f1d119db-2161-4640-829f-7d0b8388e0fe

Reply
0 Upvotes
Highlighted
HubSpot Employee

Hi @KingswaySoft ,

 

The only thing that jumps out to me is maybe the URL encoding of your redirect_uri. Can you double check that the URL isn't being double encoded?

 

Additionally, can you test this exact request in Postman, outside of the context of your code? Here's a Postman collection to edit - https://www.getpostman.com/collections/a231c29e2ec393f87b2a

 

You can import that to postman via File > Import > Import from URL. Then, edit the request to include your client id and client secret. Go through the first step of the flow in your browser to get a new code parameter, and then copy/paste into the Postman collection and Post. Let me know the results.

Reply
0 Upvotes
New Contributor

Hi @robertainslie , I'm sure the redirect_uri is not double encoded.

I have just tried in Postman and got the same 500 error result.

This error only happens to a particular HubSpot instance, the portalId is 163004 if it helps for you investigation.

 

Reply
0 Upvotes
HubSpot Moderator

Hi, @KingswaySoft.

 

I'll be taking this over for @robertainslie. I've just sent you a direct message.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
New Contributor

Hi @IsaacTakushi , I responded to your direct message yesterday, can you please check and update us if you found anything?

Reply
0 Upvotes
HubSpot Moderator

Hi, @KingswaySoft.

 

Thanks for your patience.

 

I've run nearly 40 tests today with your auth URL, different accounts, and different users and have an update!

 

I can consistently reproduce 500 errors from this endpoint after authenticating your app with a Super Admin who has Sales Professional or Enterprise access — the same permission set as the user in account 163004.

 

Once a user with both the Super Admin and Sales Professional/Enterprise roles triggers a 500 error, they are unable to connect the app under any circumstances. Revoking the roles and even changing the auth URL have no effect — the endpoint will continue to return 500 errors for that user.

 

Curiously, other combinations of roles work perfectly. An Admin with Sales Professional/Enterprise access can connect and disconnect the app any time, as can a Super Admin with no Sales Professional/Enterprise seat.

 

I can continue to dig into this issue. In the meantime, could you have a different user with the appropriate permissions in account 163004 connect your app? (Depending on your client's needs, either of the combinations above will work.)

 

Please let me know if I can clarify further.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
New Contributor

Hi @IsaacTakushi , thank you for the update, glad to hear you can reproduce the issue.

We have suggested our client to try with a different user for now, please keep us posted if you find anything else. We are eager to know the root cause of this issue.

Reply
0 Upvotes