Custom auth token not working in api calls

  • Goal: I need to have a login page that calls my API login to get a jwt
    I have created the custom auth token

  • Steps:

  • I have created the custom auth token





when used in an other call :

but the MY_TOKEN variable is arriving to server as MY_TOKEN and not the content of the variable:
...,"user-agent":"Retool/2.0 (+https://docs.tryretool.com/docs/apis)","authorization":"Bearer MY_TOKEN","ot-baggage-requestid":"undefined"...

not sure what is wrong here

Just a quick sanity check, in the Credentials section of your API Query, are you passing your bearer token as Bearer MY_TOKEN or Bearer {{ MY_TOKEN }}.

From your first screenshot, it looks like you're sending the string MY_TOKEN instead of the embedded variable.

I have tried both options but more this one string MY_TOKEN

If I use Bearer {{ MY_TOKEN }}. I received authorization .."authorization":"Bearer {{ MY_TOKEN }}"...

with Bearer MY_TOKEN I get ... authorization":"Bearer MY_TOKEN"..

I'm not sure why your request is being made with the string literal instead of the embedded expression. When I try in a demo cloud app, MY_TOKEN is in scope for the API request.

Another way to do it is by declaring the variable you're using to pass the token under Additional Scope and then adding the additionalScope: {} parameter when you call the query.

This is strange as it looks like your setup is just fine (especially from your console) -- I have a similar resource setup and the token is passing through properly. The only difference I can see between what you have shared and what I do is that I also added an additional Refresh Auth workflow step that runs on every query which is basically just a copy/paste of the original token grab.

The only other thing I noticed is that your resource is using http2 and mine is using http1 so it could be at the resource level (and maybe something changed in the Retool backend for this)

ETA: setting for Running every Query:
image

1 Like

I have tried the scope, but I am not uderstanding it, and what is apiAditionalScope
Thank you

Hey @Kilian - thanks for reaching out. :wave:

At first glance, everything about your resource configuration seems to be in order. It's possible that your custom authentication flow just isn't running, though. I'd recommend configuring a refresh flow that runs on a regular basis - similar to what @pyrrho pointed out - or defining a login test URL.

Let me know what you try if you have any follow-up questions!

Finally I redone al the process from scrach and it works, not sure were the error was but now is working