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

vbosma
Deputy Chef II
Deputy Chef II

Yes, this is the way for now. Thank you for your reply.

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.

Hi @francbaviello you can see the error of the first call in my very first screenshot. It is a message that does not contain an actual status code that makes Workato give an error.

The status is 200 OK and the body contains the error. This is the reason there is no error from the HTTP action itself. 

Like you opted: I made 2 calls now, 1 going for the /token endpoint, and the next using that token so there are no more invalid tokens.

Schermafbeelding 2026-02-06 093552.png

Thank you for your inspiration/your help and thinking with me!

shivakumara
Executive Chef III
Executive Chef III

Hi @vbosma ,

I have the following question:
How often do you run this recipe?

You can also try enabling the โ€œAutomatic retryโ€ option (recommended) in your recipe.
This will help you to get the latest token in case failed get positive response.

Thanks and Regards,
Shivakumara K A




Hi @shivakumara , 

Thank you for your quick reply.
This recipe is eventdriven, so not on a schedule.

Like in my response to francbaviello, the status response from the other client is 200 OK, even though the token is invalid.
Therefor I put in the IF statement (see screenshot in same response). So the automatic retry is no option.

If you have any other ideas I would like to hear them.