Rest API "Unauthorized" 401

I am trying to get data from an API by selecting start date and end date and the info displays on a graph.

So far I have made a query that generates the Bearer token, and another one that uses it to get the required information based on the dates input.
Sometimes it works, but when trying again it gets me this 401 "Unauthorized" error, although it has nothing to do with anything at all, because the same query worked 5s ago.
I also tried to have a look at the cache and disabled it just to make sure I get the right token information, I also made a delay for the data to be transfered from the get token query to the get data query. It seems to help a bit, but it crashes again after a few tries. I am sure it's not a problem with the API provider, because the requests are working, and there isn't any time frames I need to wait to make a new query.
I still think the problem is either my unprofessional and unoptimized way of making the queries or cache.

This is a ss of the token_get query witch always works (the authorization info is stored in the "edit" part of the query):

And this is the actual problematic query reservation_income:


This is the image when the code works:


And here it is when it doesn't (nothing is different):

I am about to give up on life with these types of errors, thanks in advance for any recommendations guys.

Hi @Sarunas_Rodriguez,

Thanks for reaching out!

I highly recommend seeing if custom auth would work for your resource. You can try removing the token_get query, and instead, setting up custom authentication on Reservation Income.

You can have an auth step that handles the post request you have in token_get, you can add a JS step to do any parsing, and then a define a variable step with the token. Then, you can pass the variable token to the Reservation Income resource headers. That way, the token will be applied automatically to all Reservation Income queries & you don't need to add it anywhere in the app queries.

Does the token ever expire? You can add steps for that as well.

Hope that helps! :crossed_fingers: