# Adding Bearer token as a HTTP Header

**URL:** https://discourse.nodered.org/t/adding-bearer-token-as-a-http-header/60408
**Category:** General
**Tags:** security
**Created:** [27 March 2022 14:35 UTC](https://discourse.nodered.org/t/adding-bearer-token-as-a-http-header/60408 "2022-03-27T14:35:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lobster87](https://avatars.discourse-cdn.com/v4/letter/l/8491ac/32.png) [@lobster87](https://discourse.nodered.org/u/lobster87)
#### Post date: [27 March 2022 14:35 UTC](https://discourse.nodered.org/t/adding-bearer-token-as-a-http-header/60408/1 "2022-03-27T14:35:18Z")

</div>

Hello,

I try to create HTTP flows in which users try to authenticate and after positive verification, she or he get a response with a header that contains the token. So far, based on [Authenticating Node-RED using JSONWebToken - Part 2 - Compose Articles](https://www.compose.com/articles/authenticating-node-red-using-jsonwebtoken-part-2/) and [Header-based Authorization (flow) - Node-RED](https://flows.nodered.org/flow/61cc25aaf9017185bc026e5bd690cb5b) I have created such two flows:

 ![obraz](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/5/451c227a90dc755fc4055ffa727445ea6f565901.png)

The first one is a simple GET with an authentication form as a template and response. The second one POST with an authentication form, a function that retrieves a user from the database. Now I do not know:

- how to verify if user exists
- after positive verification how to create the token and add it to a response header.

---

<div class="post-metadata">

### Author: ![michaelblight](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelblight/32/445_2.png) [@michaelblight](https://discourse.nodered.org/u/michaelblight)
#### Post date: [28 March 2022 02:50 UTC](https://discourse.nodered.org/t/adding-bearer-token-as-a-http-header/60408/2 "2022-03-28T02:50:20Z")

</div>

The http-out node can be sent `msg.headers` containing json like that below:

```auto
{
    "Authorization": "Bearer 12345678"
}

```

where "12345678" is your token.

---

<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: [27 May 2022 02:50 UTC](https://discourse.nodered.org/t/adding-bearer-token-as-a-http-header/60408/3 "2022-05-27T02:50:27Z")

</div>

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