Help: Getting a 401 saying "Authentication credentials not found" for only one customer!

Hi all,

Hopefully folks can help out! Our app is working just fine for most people - they can connect via OAuth and everything goes swimmingly.

However, for one specific customer we’re getting a 401 response from the API with the following body:

{"status":"error","message":"Authentication credentials not found. This API supports both API Key and OAuth 2.0 authentication and you can find more details at https://developers.hubspot.com/docs/methods/auth/oauth-overview","correlationId":"4c128e58-3641-47e3-8dec-7ca3a6526d25","category":"INVALID_AUTHENTICATION"}

If you look at the request we’re sending, the Authorization header is definitely there along with an OAuth token:

That is a valid, current OAuth Token.

I’ve verified this in the Monitoring section of the App management portal.

I’ve got the request IDs etc if anyone can help. Worth noting again this exact code path works fine for other accounts, just for some reason not for this specific account. I may be doing something weird but who knows. I’m using the official Ruby Gem to integrate: GitHub - HubSpot/hubspot-api-ruby: HubSpot API Ruby Client Libraries for V3 version of the API · GitHub

Thanks in advance.

Hello @STeam0 , thank you for reaching out to our Community!

This error message typically suggests that the authentication (API Key/OAuth access token) was missing when sending the HubSpot API request.

I was able to find these Community posts with more details:

Post 1

Post 2

skimura mentioned :

$headers = @{ 'Content-Type'='application/json'
 'Authorization'= 'Bearer ' + $PrivateAppKey
}

could you please confirm if this setting is correct?

I hope this information helps.

Pam

Hi @PamCotton, thanks for that but I don’t think that’s the issue here - I’m definitely adding the header and as I said it’s working with the exact same code path for a number of other users - it’s definitely something specific to this one account. I wonder if there’s something about the subscription?

I’m using Axios to make calls and had this error. I fixed it by making sure the body of the post request comes before the headers. So :

axios.post(url, data, { 
 headers: {...}
})

instead of:

axios.post(url, {
 headers: {...},
 data,
}

Chris this one did it for me thank you so much, I was at it for 2 days lol. I know I added the access token so for sanity check I added logs which I checked on the hs cli logs and bingo my token was there. Just followed your advice and I got it fixed, again thanks a lot!!!

Chris, thank you so much for your suggestion! Really saved my sanity here.

I also use axios and this was just the thing that made it work!