cancel
Showing results for 
Search instead for 
Did you mean: 

API call when using HTTP-connector fails because invalid_token was used in oauth2

vbosma
Deputy Chef II
Deputy Chef II

Hi, when reaching out to an application with the HTTP connector I often get an error for "invalid_token, the access token provided has expired". This seems to happen every time a new token is needed for a call. When repeating the job, the call goes just fine. 

First call result:

Schermafbeelding 2026-02-05 124927.pngSchermafbeelding 2026-02-05 131738.png

 

 

 

 

 

Second call result:

Schermafbeelding 2026-02-05 1322372.png

Schermafbeelding 2026-02-05 131836.png

Schermafbeelding 2026-02-05 1318521.png

 

Does anyone have an idea what the cause could be? Also I never encounter this problem using Postman.

To mee it seems like the token was used too quickly for the target application to be able to validate the token. 
In the debug of the HTTP request I see no details of the actual headers/payload/response
What is the best-practice solution I could try?

I have not seen anything like a delay in the HTTP connector settings and it seems to extreme to make a custom connector.

The target application accepts the usual Oauth2 flow, with grant_type: client_credentials.
This results in a bearer token for all following calls.

I look forward to your inspiration, also: please let me know if this is not the right place for this question.

Kind regards,

Vincent

 

1 ACCEPTED SOLUTION

Hi @vbosma, for the First workaround can you send the response/error of the http action?

How the second workaround, you can create two http invocation if possibile: 

  • First invocation: you send http request at url to receive in the response the access token;
  • Second invocation: you send http request with authentication token.

View solution in original post

11 REPLIES 11

shivakumara
Executive Chef III
Executive Chef III

Hi @vbosma ,

In the retry mechanism, also inspect the error response body to identify token-expiration errors.

If the error is related to an expired access token, skip the retry. Instead, handle the error by first refreshing the token explicitly (preferably using a separate callable recipe or function dedicated to token management).

Once the token is refreshed, re-execute the same business logic within the error handling block, rather than relying on multiple retries.

This approach avoids unnecessary retries, reduces failed jobs, and results in more predictable behavior when handling token expiration in Workato.

@shivakumara This seems like another way to do the token management, I agree. Also thinking about the amount of consumed tasks. I think this might be the way after some time with a bit more experience (and excessive tasks-usage). Thank you!