# \[SOLVED\] Having problems with creating a JWT token through API

**URL:** <https://forum.litium.com/t/solved-having-problems-with-creating-a-jwt-token-through-api/1973>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [April 8, 2021, 1:06pm UTC](https://forum.litium.com/t/solved-having-problems-with-creating-a-jwt-token-through-api/1973 "2021-04-08T13:06:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anek](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@anek](https://forum.litium.com/u/anek)\
**Post date:** [April 8, 2021, 1:06pm UTC](https://forum.litium.com/t/solved-having-problems-with-creating-a-jwt-token-through-api/1973/1 "2021-04-08T13:06:37Z")

</div>

Im trying to create a JWT token like it [says in the docs](https://docs.litium.com/documentation/architecture/web-api) to send in products from our PIM integration via the connector, but getting back 404 or 400.  
Im probably just missunderstanding it but im sending the POST with grant\_type, client\_id, and client\_secrets as x-www-form-urlencoded in the body. Have also tried to send them as url parameters.

What am i missing here?

EDIT: i spelled oauth wrong and had a trailing / in the url

Litium version: 7.6.1

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [April 8, 2021, 1:10pm UTC](https://forum.litium.com/t/solved-having-problems-with-creating-a-jwt-token-through-api/1973/2 "2021-04-08T13:10:02Z")

</div>

Take a look at this:

> [@Create JWT token from code](https://forum.litium.com/t/create-jwt-token-from-code/1342):
>
> How can I create a JWT token for a user and work with [OnlyJwtAuthorization] from backend without the user calling /Litium/OAuth/token endpoint? Litium version: 7.0

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [April 8, 2021, 1:15pm UTC](https://forum.litium.com/t/solved-having-problems-with-creating-a-jwt-token-through-api/1973/3 "2021-04-08T13:15:44Z")

</div>

Is the URL you’re using correct and accessible?

I tested now with Postman and got a token back:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/52621a26dc48542532cbbcc16944fe78684d3795.png)

`{{server}}` is just a variable with my local domain. And I have a service account set up with these credentials.

---

<div class="post-metadata">

**Author:** ![anek](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@anek](https://forum.litium.com/u/anek)\
**Post date:** [April 8, 2021, 1:31pm UTC](https://forum.litium.com/t/solved-having-problems-with-creating-a-jwt-token-through-api/1973/4 "2021-04-08T13:31:18Z")

</div>

Yeah it’s correct and up and running.

 ![bild](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/3587ad8012ba5c0b41a8b4afcf6f5288d9bff823.png)

How is your service account set up? Thinking that it might have something with that to do

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [April 8, 2021, 1:41pm UTC](https://forum.litium.com/t/solved-having-problems-with-creating-a-jwt-token-through-api/1973/5 "2021-04-08T13:41:14Z")

</div>

The URL in your image looks incorrect, it says `oath` (missing the u) and has a trailing slash. Can you test with `http://localhost:8080/Litium/oauth/token` instead?

---

<div class="post-metadata">

**Author:** ![anek](https://avatars.discourse-cdn.com/v4/letter/a/f4b2a3/32.png) [@anek](https://forum.litium.com/u/anek)\
**Post date:** [April 8, 2021, 1:43pm UTC](https://forum.litium.com/t/solved-having-problems-with-creating-a-jwt-token-through-api/1973/6 "2021-04-08T13:43:25Z")

</div>

Oh i should’ve noticed that, now it works haha. Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [May 6, 2021, 1:43pm UTC](https://forum.litium.com/t/solved-having-problems-with-creating-a-jwt-token-through-api/1973/7 "2021-05-06T13:43:36Z")

</div>

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