# Credentials and HTTP

**URL:** <https://discourse.nodered.org/t/credentials-and-http/65266>\
**Category:** General\
**Tags:** http-request\
**Created:** [18 July 2022 12:58 UTC](https://discourse.nodered.org/t/credentials-and-http/65266 "2022-07-18T12:58:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramona10](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@ramona10](https://discourse.nodered.org/u/ramona10)\
**Post date:** [18 July 2022 12:58 UTC](https://discourse.nodered.org/t/credentials-and-http/65266/1 "2022-07-18T12:58:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [18 July 2022 13:02 UTC](https://discourse.nodered.org/t/credentials-and-http/65266/2 "2022-07-18T13:02:53Z")

</div>

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

> **[Authorization - HTTP | MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization)**
>
> The HTTP Authorization request header can be used to provide credentials that authenticate a user agent with a server, allowing access to a protected resource.

---

<div class="post-metadata">

**Author:** ![ramona10](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@ramona10](https://discourse.nodered.org/u/ramona10)\
**Post date:** [18 July 2022 13:09 UTC](https://discourse.nodered.org/t/credentials-and-http/65266/4 "2022-07-18T13:09:54Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/2061d82971e186a8564142eeda7ff0722e838f6f.png)

Like this? Because it's still not working

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [18 July 2022 13:25 UTC](https://discourse.nodered.org/t/credentials-and-http/65266/5 "2022-07-18T13:25:55Z")

</div>

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

```auto
[{"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.

---

<div class="post-metadata">

**Author:** ![ramona10](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@ramona10](https://discourse.nodered.org/u/ramona10)\
**Post date:** [18 July 2022 13:27 UTC](https://discourse.nodered.org/t/credentials-and-http/65266/6 "2022-07-18T13:27:05Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/f/dfc0024317a4785648af87c9d3c3ab7dee64c90b.png)  
The flow looks like this. The token is simply a string, a token from github

---

<div class="post-metadata">

**Author:** ![ramona10](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@ramona10](https://discourse.nodered.org/u/ramona10)\
**Post date:** [18 July 2022 13:31 UTC](https://discourse.nodered.org/t/credentials-and-http/65266/7 "2022-07-18T13:31:25Z")

</div>

It works, thank you

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 August 2022 13:32 UTC](https://discourse.nodered.org/t/credentials-and-http/65266/8 "2022-08-01T13:32:14Z")

</div>

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