# Getting Invalid JWT when running Headless Bot Sample

**URL:** <https://devforum.zoom.us/t/getting-invalid-jwt-when-running-headless-bot-sample/120314>\
**Category:** Meeting SDK\
**Created:** [November 4, 2024, 10:32pm UTC](https://devforum.zoom.us/t/getting-invalid-jwt-when-running-headless-bot-sample/120314 "2024-11-04T22:32:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![noahviktorschenk](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/noahviktorschenk/32/74873_2.png) [@noahviktorschenk](https://devforum.zoom.us/u/noahviktorschenk)\
**Post date:** [November 4, 2024, 10:32pm UTC](https://devforum.zoom.us/t/getting-invalid-jwt-when-running-headless-bot-sample/120314/1 "2024-11-04T22:32:56Z")

</div>

Hey there,

So I have been using the Headless bot sample for a while now with no issues. I am currently rewriting it to be able to handle bigger meetings, but now I am getting `Invalid JWT` half of the time I run the image.

It is not consistent, but around 50% of the times I run `docker compose up` I get `authentication failed because the JWT is invalid`.

Here is the `generateJWT` function:

```cpp
void Zoom::generateJWT(const string& key, const string& secret) {

    m_iat = std::chrono::system_clock::now();
    m_exp = m_iat + std::chrono::hours{24};

    m_jwt = jwt::create()
            .set_type("JWT")
            .set_issued_at(m_iat)
            .set_expires_at(m_exp)
            .set_payload_claim("appKey", claim(key))
            .set_payload_claim("tokenExp", claim(m_exp))
            .sign(algorithm::hs256{secret});
}

```

Here is an example of a JWT that is invalid:  
`eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBLZXkiOiJRODdJdENUSFIzeVM5ZUtoakd6RXp3IiwiZXhwIjoxNzMwODQ0MDMyLCJpYXQiOjE3MzA3NTc2MzIsInRva2VuRXhwIjoxNzMwODQggpLGU0cz80K5k0fGXBrBMuBkowc0-vjQ`

I have tried using both the development and the production ID and secret. I’m not sure if I should share those here.

Thanks,  
Noah Schenk

---

<div class="post-metadata">

**Author:** ![amanda-recallai](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/amanda-recallai/32/44747_2.png) [@amanda-recallai](https://devforum.zoom.us/u/amanda-recallai)\
**Post date:** [November 13, 2024, 12:24am UTC](https://devforum.zoom.us/t/getting-invalid-jwt-when-running-headless-bot-sample/120314/2 "2024-11-13T00:24:02Z")

</div>

Hey Noah, if you’re experiencing intermittent ‘Invalid JWT’ errors while running the Headless bot sample, you might want to check out the Recall.ai API.

It’s a simple 3rd party API that lets you use meeting bots to get raw audio/video/metadata from meetings without you needing to spend months to build, scale and maintain these bots.

Here are the API docs:

> **[Recall.ai](https://docs.recall.ai)**

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [November 13, 2024, 8:43am UTC](https://devforum.zoom.us/t/getting-invalid-jwt-when-running-headless-bot-sample/120314/3 "2024-11-13T08:43:33Z")

</div>

@noahviktorschenk ,

Have you decoded the JWT and compared the failed and successful claims? Here’s a video on debugging JWT that you can check out:

[![](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/8/6/862f511d17afc1136c639b9855a410f19c6fe6fc.jpeg "Decoding JWT for Authorization Errors for Zoom Meeting SDK") ](https://www.youtube.com/watch?v=F3l5RJoEKP4)

---

<div class="post-metadata">

**Author:** ![noahviktorschenk](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/noahviktorschenk/32/74873_2.png) [@noahviktorschenk](https://devforum.zoom.us/u/noahviktorschenk)\
**Post date:** [November 16, 2024, 12:55pm UTC](https://devforum.zoom.us/t/getting-invalid-jwt-when-running-headless-bot-sample/120314/4 "2024-11-16T12:55:23Z")

</div>

No, I did not think of that, I will try it, Thank you!

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [November 18, 2024, 3:41am UTC](https://devforum.zoom.us/t/getting-invalid-jwt-when-running-headless-bot-sample/120314/5 "2024-11-18T03:41:52Z")

</div>

@noahviktorschenk are you still have issues with this? If you are, share a sample of your JWT token here, and tag me in your response

---

<div class="post-metadata">

**Author:** ![noahviktorschenk](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/noahviktorschenk/32/74873_2.png) [@noahviktorschenk](https://devforum.zoom.us/u/noahviktorschenk)\
**Post date:** [November 18, 2024, 6:48pm UTC](https://devforum.zoom.us/t/getting-invalid-jwt-when-running-headless-bot-sample/120314/6 "2024-11-18T18:48:47Z")

</div>

@chunsiong.zoom Sorry for not marking it as resolved, but yes, the issue seems to have resolved itself. I have not had the issue since my last message. I did not change anything so not sure what was causing it. Thank you for the help.

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [November 19, 2024, 5:35am UTC](https://devforum.zoom.us/t/getting-invalid-jwt-when-running-headless-bot-sample/120314/7 "2024-11-19T05:35:33Z")

</div>

Closed on November 19, 2024, 5:35am UTC


