# Expired or invalid access token error code

**URL:** <https://community.hubspot.com/t/expired-or-invalid-access-token-error-code/73162>\
**Category:** APIs & Integrations\
**Created:** [January 18, 2023, 9:36am UTC](https://community.hubspot.com/t/expired-or-invalid-access-token-error-code/73162 "2023-01-18T09:36:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![testctrl](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@testctrl](https://community.hubspot.com/u/testctrl)\
**Post date:** [January 18, 2023, 9:36am UTC](https://community.hubspot.com/t/expired-or-invalid-access-token-error-code/73162/1 "2023-01-18T09:36:03Z")

</div>

Hello,

I am trying to refresh the token when it expires. Up until recently, the error code received from HubSpot on a “The access token is expired or invalid” message was 401. However, lately I have been also seeing 404 code in these cases. So now I see \*both\* error codes in the same catch. Is it intentionally? Which error code should I rely on when attempting to handle this error?

 ![Screen Shot 2023-01-18 at 11.54.07.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/e/1/e1296371a6ddfbf93fcca93baf6612746eb733ee.png)

 ![Screen Shot 2023-01-18 at 11.54.22.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/1/11e29077ba70ac292537a0ded6f1d1624f1b5e6f.png)

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [January 19, 2023, 9:55pm UTC](https://community.hubspot.com/t/expired-or-invalid-access-token-error-code/73162/2 "2023-01-19T21:55:36Z")

</div>

Hi, @testctrl 👋 Thanks for posting. To clarify, this is the endpoint you are referring to? — [Refresh OAuth 2.0 access token](https://legacydocs.hubspot.com/docs/methods/oauth2/refresh-access-token)

Additionally, you are saying that you are getting back two separate 400 errors in the same response? To make sure I understand correctly.

Thanks for the additional information!

— Jaycee

---

<div class="post-metadata">

**Author:** ![testctrl](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@testctrl](https://community.hubspot.com/u/testctrl)\
**Post date:** [January 22, 2023, 8:27am UTC](https://community.hubspot.com/t/expired-or-invalid-access-token-error-code/73162/3 "2023-01-22T08:27:34Z")

</div>

It happens on any endpoint - when the token is expired.

Sometimes I receive 404, sometimes 401. Not simulatenously, of course.

However, I can receive both responses on the same endpoint. My guess is that there are two different servers on your side - and they behave differently in this case.

---

<div class="post-metadata">

**Author:** ![testctrl](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@testctrl](https://community.hubspot.com/u/testctrl)\
**Post date:** [January 25, 2023, 1:41pm UTC](https://community.hubspot.com/t/expired-or-invalid-access-token-error-code/73162/4 "2023-01-25T13:41:26Z")

</div>

[@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) Hey, have you seen my reply?
