# JWT in the body

**URL:** <https://community.postman.com/t/jwt-in-the-body/56704>\
**Category:** Help Hub\
**Tags:** jwt\
**Created:** [January 18, 2024, 12:31pm UTC](https://community.postman.com/t/jwt-in-the-body/56704 "2024-01-18T12:31:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![telecoms-candidate12](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@telecoms-candidate12](https://community.postman.com/u/telecoms-candidate12)\
**Post date:** [January 18, 2024, 12:31pm UTC](https://community.postman.com/t/jwt-in-the-body/56704/1 "2024-01-18T12:31:09Z")

</div>

Hi, I have to send a request and do not know how to create a pre-request script. The issue is that the payload should be signed in JWT RS256 (Sign with private key), but the token should be sent in the body, so…

If I have the body:

```auto
    {
        "client": 31018881,
        "subMethod": null,
        "provider": "6f2dd96b-e48a-4c85-94f9-33dcec9c4acb",
        "Currency": "EUR"
    }

```

I should send this payload: `{"token": "token in RS256"}`

Some help will be appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 18, 2024, 4:51pm UTC](https://community.postman.com/t/jwt-in-the-body/56704/2 "2024-01-18T16:51:16Z")

</div>

Hey @telecoms-candidate12 👋

I don’t think that there is a straightforward way of doing that (I’m probably wrong though), there going to be a few moving parts and code to get what you need I believe.

We do have a JWT Helper under the Auth tab but as you require this in the request body, I don’t think that’s going to work for you.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/0/6/064fe206cb9f06b97f3acc2d520a48dd52d83b00.png)

I’ve never done it like this so my responses are going to be based on a bit of research and learning as i’m going. 🙏

There is this older topic which is bringing an external lib to do some of the heavy lifting:

> [@External libraries for JWT encryption and protecting the Private Key](https://community.postman.com/t/external-libraries-for-jwt-encryption-and-protecting-the-private-key/32452):
>
> Hi, In our team we work extensively with [Adobe.io](http://Adobe.io) and Experience Cloud API’s We’ve recently come across a library that seems to meet our needs when it comes to encrypting a JWT token. For this we are using the Pre-request Script capability of Postman and this library [jsrsasign - cryptography library in JavaScript](https://kjur.github.io/jsrsasign/) Now I haven’t done a security audit on this library but I am conscious that the private key we are using could in fact be sent to a third party, obviously not good. So my question i…

This is also something similar which was asked and answered by someone who works at Postman so I could ask him to help out here.

> <https://stackoverflow.com/questions/59383521/postman-pre-request-script-to-create-jwt-for-google-service-account>

A lot of people are mentioned this util lib that could be brought into Postman via a CDN and stored at the global level. I can’t vouch for this though so it’s up to you if that’s something you want to use.

> **[postman-util-lib](https://joolfe.github.io/postman-util-lib/)**
>
> :rocket: A crypto utility library to be used from Postman Pre-request and Tests script tabs.

---

<div class="post-metadata">

**Author:** ![telecoms-candidate12](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@telecoms-candidate12](https://community.postman.com/u/telecoms-candidate12)\
**Post date:** [January 18, 2024, 5:51pm UTC](https://community.postman.com/t/jwt-in-the-body/56704/3 "2024-01-18T17:51:53Z")

</div>

Thanks for your help, I will check that.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [February 17, 2024, 5:52pm UTC](https://community.postman.com/t/jwt-in-the-body/56704/4 "2024-02-17T17:52:00Z")

</div>

Closed on February 17, 2024, 5:52pm UTC

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