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.
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...
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.
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!