Filling http request field automatically

Hi,
I am using two seperate http request nodes separately to access a service's api in Node-Red.
The first one requests a token used for an extra level of authentication which is returned in the debug tab. The second requires this token, but I want to know if there is any way to automatically get the token into the authentication field, any help would be appreciated. Pictures are below.

image
image
image
image

So far I can only manual set the following fields: Use authenticaton, type, username, password and token. Is there ways to automatically set at least the passwords if not all?

Hi @DillonW

the HTTP Request node does not let you provide the username/password fields through msg properties. But you can set the required HTTP headers yourself - which achieves the same result.

Leave the 'use authentication' box unticked and in a Function node do:

msg.headers = {};
msg.headers['Authorization'] = "Bearer "+YOUR_ACCESS_TOKEN
return msg;

Obviously you have to figure out where to get YOUR_ACCESS_TOKEN from...

Hi, I have done an attempt. I tried storing the token received from the first http request node into a flow variable and then use this in the function as you said. But this gave an error as shown.
image
image
image
image

But if I manually copied it into the field(after trying this way first) it works in the copied format.

It looks like you are missing a space after the word Bearer. Your code is generating a header like: BearerYOUTOKEN where it should be Bearer YOURTOKEN.

tried adding the space, still get the same error. I've checked the output and the token is the same as from the first request node.
image
image

I don't know what to suggest... that is the right format for the Bearer header.

At this point I would use something like https://requestbin.fullcontact.com in order to compare the exact requests sent when the token is hardcoded into the node versus when you set the header.

I tried adding the links to the site, but it doesn't register, always changes back to the default, is that normal? Any other ways to check?

Thanks. It still hasn't worked thus far

Hi @DillonW, where you able to solve this issue ?

I can confirm this work for me pretty good!