Credentials and HTTP

Hello!
I have been trying to link the credentials node to a http request, using a bearer token, but I am not sure how.
Msg does not have a property of token for credentials. How am I supposed to link the token from the credentials to the http token blank space?

You would not use the config authorization setting. You pass the bearer token in the headers by setting msg.headers.Authorization.

Like this? Because it's still not working

Is the token saved as Bearer token_string or just the token string?
If just the token then you would do something like this

[{"id":"77bc3cd.14f5fc4","type":"inject","z":"30af2d3e.d94ea2","name":"output from credential node","props":[{"p":"token","v":"1234567qwerty","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":230,"y":700,"wires":[["4270f0b0.5b93a8"]]},{"id":"4270f0b0.5b93a8","type":"change","z":"30af2d3e.d94ea2","name":"","rules":[{"t":"set","p":"headers","pt":"msg","to":"{\"Authorization\": \"Bearer \" & $$.token}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":660,"wires":[["8bdfd8b8.1ec208","9fb9e4d2.39dcd8"]]},{"id":"8bdfd8b8.1ec208","type":"http request","z":"30af2d3e.d94ea2","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://some.site.com","tls":"","persist":false,"proxy":"","authType":"","x":630,"y":720,"wires":[[]]},{"id":"9fb9e4d2.39dcd8","type":"debug","z":"30af2d3e.d94ea2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":640,"wires":[]}]

You may also have to base64 encode the string if it is not already.


The flow looks like this. The token is simply a string, a token from github

It works, thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.