APIs & Integrations

KingswaySoft
Member

Access token return 500 Internal Server Error

SOLVE

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?

0 Upvotes
1 Accepted solution
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Access token return 500 Internal Server Error

SOLVE

Hi, @KingswaySoft.

 

So sorry for not being in touch.

 

This should now be fully resolved. We found that when all possible scopes were requested and granted, it caused a timeout that triggered the 500 errors. This issue was rare because it only occurred when users had access to tools like transactional email, which most HubSpot customers do not have.

 

One of my other colleagues will notify the owners in account 163004 directly.

 

Thank you for your patience throughout this long process.

Isaac Takushi

Associate Certification Manager

View solution in original post

0 Upvotes
11 Replies 11
robertainslie
HubSpot Employee
HubSpot Employee

Access token return 500 Internal Server Error

SOLVE

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.

0 Upvotes
KingswaySoft
Member

Access token return 500 Internal Server Error

SOLVE

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

0 Upvotes
robertainslie
HubSpot Employee
HubSpot Employee

Access token return 500 Internal Server Error

SOLVE

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.

0 Upvotes
KingswaySoft
Member

Access token return 500 Internal Server Error

SOLVE

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.

 

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Access token return 500 Internal Server Error

SOLVE

Hi, @KingswaySoft.

 

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

Isaac Takushi

Associate Certification Manager
0 Upvotes
KingswaySoft
Member

Access token return 500 Internal Server Error

SOLVE

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

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Access token return 500 Internal Server Error

SOLVE

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

Associate Certification Manager
0 Upvotes
KingswaySoft
Member

Access token return 500 Internal Server Error

SOLVE

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.

0 Upvotes
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Access token return 500 Internal Server Error

SOLVE

Hi, @KingswaySoft.

 

So sorry for not being in touch.

 

This should now be fully resolved. We found that when all possible scopes were requested and granted, it caused a timeout that triggered the 500 errors. This issue was rare because it only occurred when users had access to tools like transactional email, which most HubSpot customers do not have.

 

One of my other colleagues will notify the owners in account 163004 directly.

 

Thank you for your patience throughout this long process.

Isaac Takushi

Associate Certification Manager
0 Upvotes
LPM
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Access token return 500 Internal Server Error

SOLVE

Hi @IsaacTakushi . I'm having the same issue when trying to get an access token for a test app I'm trying on a dev account. What was the solution in the end?

 

Sorry, ignore me. Was being dumb and found a typo.

0 Upvotes
KingswaySoft
Member

Access token return 500 Internal Server Error

SOLVE

Thanks @IsaacTakushi for the update. Glad to hear the issue is resolved.