I’m using http requests to hubspot for additional functionality than the hubspot node. When the oauth2 expires, hubspot returns a 400 error to n8n, the error code they’re using for expired tokens. Looking at other posts here it seems that N8N waits for the 401 response before refreshing the token. Is there any workaround?
Actually, according to the hubspot api logs it’s serving a 401 error, but this is showing as a 400 error in N8N. If I reconnect the oauth in N8N it works fine again until the token expires 6 hours later.
Thank you. I hoped it might’ve been because I didn’t use the grant_type=refresh_token query parameter, but 6 hours later the token’s expired again and N8N is showing a 400 error
Just an update
I used postman to get an access token from hubspot, which returned a refresh token.
I’ve passed this refresh token in the parameters via N8N and it’s reconnected.
Assuming this is the solution, I’ll let you know in 6 hours!!
Still no success!
Hubspot expects the grant_type=refresh_token and refresh_token=xxxxxx to be passed in the body of the Oauth2 request. Is there any way of adding to the body?
Here’s a link to their Documentation:
N8N still shows a 400 error when the token is expired, but hubspots logs suggest it’s served a 401
That should be handled for you. What authentication type are you using in the HTTP node? Because you need to use the OAuth2 type. Also, you can generate an API Key in HubSpot and use the authentication Header OAuth.
I’m using Oauth2, it connects fine but doesn’t refresh the token.
When the token expires it shows as a 400 error in N8N.
I assumed Oauth2 would be more secure than using a header oauth, but the header one works fine
Yes, I’m using their associations, crm cards and engagement endpoints so couldn’t do it with the hubspot node. I’ve reverted back to authentication with the api key instead - it’s working fine - and it’s only communicating between an app on localhost and hubspot, so assuming this will be safe enough?
@ljcn gotcha. I thought you were working with the node. I need to have a look a see why it’s not working with the HTTP node. Yes, in the meantime, using the API Key should be safe.