# Java API call using JWT token returns 401

**URL:** <https://devforum.zoom.us/t/java-api-call-using-jwt-token-returns-401/32163>\
**Category:** App Marketplace\
**Created:** [October 5, 2020, 6:22am UTC](https://devforum.zoom.us/t/java-api-call-using-jwt-token-returns-401/32163 "2020-10-05T06:22:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![baljit.karwal](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@baljit.karwal](https://devforum.zoom.us/u/baljit.karwal)\
**Post date:** [October 5, 2020, 6:22am UTC](https://devforum.zoom.us/t/java-api-call-using-jwt-token-returns-401/32163/1 "2020-10-05T06:22:24Z")

</div>

**Description**  
I am trying to implement Java API using JWT to call create meetings.  
Used [jwt.io](http://jwt.io) Java library to generate a token in Java code. Token gets generated and validated through [jwt.io](http://jwt.io) just to make sure that I have created the right token. However, when I pass that token in API call as Bearer , it returns 401 HTTP response in JAVA API response. If I try to use the same token in postman, it returns code “124”.  
If I use a token code generated through the Zoom platform inside the app works fine in postman and code.

**Error**  
Receiving HTTP Response 401 in HTTP connection response.  
Receiving below JSON in postman if using JWT created through JWT library:  
{  
“code”: 124,  
“message”: “Invalid access token.”  
}

**Which App?**  
JWT

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [October 5, 2020, 8:37pm UTC](https://devforum.zoom.us/t/java-api-call-using-jwt-token-returns-401/32163/2 "2020-10-05T20:37:37Z")

</div>

Hey @baljit.karwal,

Please see my post here:

> [@Server returned HTTP response code: 401. Rest implementation in java](https://devforum.zoom.us/t/server-returned-http-response-code-401-rest-implementation-in-java/956/4):
>
> I am getting the same response in my java code as well. Any solution?

Thanks,  
Will

---

<div class="post-metadata">

**Author:** ![baljit.karwal](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@baljit.karwal](https://devforum.zoom.us/u/baljit.karwal)\
**Post date:** [October 5, 2020, 10:00pm UTC](https://devforum.zoom.us/t/java-api-call-using-jwt-token-returns-401/32163/3 "2020-10-05T22:00:28Z")

</div>

Thanks @will.zoom, I will try this today and keep you posted.

---

<div class="post-metadata">

**Author:** ![baljit.karwal](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@baljit.karwal](https://devforum.zoom.us/u/baljit.karwal)\
**Post date:** [October 5, 2020, 10:59pm UTC](https://devforum.zoom.us/t/java-api-call-using-jwt-token-returns-401/32163/4 "2020-10-05T22:59:08Z")

</div>

It worked when I passed “iss” as “api\_key” in my claims to JWT.  
Below simple JWT create worked to create valid token using “[https://github.com/auth0/java-jwt”:](https://github.com/auth0/java-jwt%E2%80%9D:)  
JWT.create().withClaim(“iss”, apiKey).withClaim(“exp”, tokenExpiryTimestamp).sign(algorithm);

Thanks  
Baljit

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [October 6, 2020, 3:15pm UTC](https://devforum.zoom.us/t/java-api-call-using-jwt-token-returns-401/32163/5 "2020-10-06T15:15:25Z")

</div>

Hey @baljit.karwal,

I’m glad this did the trick! 💯

Best,  
Will

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [November 6, 2020, 1:15am UTC](https://devforum.zoom.us/t/java-api-call-using-jwt-token-returns-401/32163/6 "2020-11-06T01:15:46Z")

</div>

Closed on November 6, 2020, 1:15am UTC

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