# Help with API Token and message

**URL:** <https://discourse.nodered.org/t/help-with-api-token-and-message/41827>\
**Category:** General\
**Created:** [1 March 2021 15:32 UTC](https://discourse.nodered.org/t/help-with-api-token-and-message/41827 "2021-03-01T15:32:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sfedo](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sfedo](https://discourse.nodered.org/u/sfedo)\
**Post date:** [1 March 2021 15:32 UTC](https://discourse.nodered.org/t/help-with-api-token-and-message/41827/1 "2021-03-01T15:32:06Z")

</div>

Hello,

I'm using API with bearer auth and http request node. I have a function to set the token and 2 inputs as JSON. Atm I'm using it like this:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/469bd693e26b2b56310d7ec441b842a0c2a7b125.png)

This is the function:

```auto
msg.headers = {
    Authorization: "Bearer "+ flow.get("Token")
};
return msg;
 

```

The way I did show above works, but it looks not the way it should be done.

Is there a way to combine messages with 2 topics? Can it be done with join node?

I need to have msg.payload and msg.headers for auth

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 March 2021 15:51 UTC](https://discourse.nodered.org/t/help-with-api-token-and-message/41827/2 "2021-03-01T15:51:05Z")

</div>

When you trigger the inject node it will send one message to the Function node and one to the Request node.

As you want the Function node to set `msg.headers` before the message is passed to the Request node, delete the wires connecting the Inject and Request nodes.

---

<div class="post-metadata">

**Author:** ![sfedo](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sfedo](https://discourse.nodered.org/u/sfedo)\
**Post date:** [1 March 2021 16:06 UTC](https://discourse.nodered.org/t/help-with-api-token-and-message/41827/3 "2021-03-01T16:06:11Z")

</div>

well, it works, thank you very much.

I thought my object will just be overwritten with msg.header...

---

<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:** [15 March 2021 16:06 UTC](https://discourse.nodered.org/t/help-with-api-token-and-message/41827/4 "2021-03-15T16:06:41Z")

</div>

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