# REST API to get JWT User Assertion dynamically

**URL:** <https://community.auth0.com/t/rest-api-to-get-jwt-user-assertion-dynamically/60063>\
**Category:** Get Help\
**Created:** [March 25, 2021, 2:15pm UTC](https://community.auth0.com/t/rest-api-to-get-jwt-user-assertion-dynamically/60063 "2021-03-25T14:15:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashuotosh.syn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ashuotosh.syn/32/14581_2.png) [@ashuotosh.syn](https://community.auth0.com/u/ashuotosh.syn)\
**Post date:** [March 25, 2021, 2:15pm UTC](https://community.auth0.com/t/rest-api-to-get-jwt-user-assertion-dynamically/60063/1 "2021-03-25T14:15:56Z")

</div>

Hi,

What we are looking for an REST API to call to get the JWT token.

Like a end point to call with headers, body and private key as attached or anyotherway to get the JWT token dynamically.

Is this available or each time we will have to come here to get the same manually.

Something like below

> **[JWT.IO](https://jwt.io/)**
>
> JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.

HEADER:  
{“alg”: “RS256”,  
“typ”: “JWT”,  
“kid”: “”  
}  
PAYLOAD:  
{  
“sub”: " ",  
“jti”: " ", ---- Any ID  
“iat”: 1616667714,  
“exp”: 1616807714,  
“iss”: " ", — Client ID  
“aud”: “[https://identity.oraclecloud.com/](https://identity.oraclecloud.com/)”  
}

Thanks!

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 29, 2021, 7:46pm UTC](https://community.auth0.com/t/rest-api-to-get-jwt-user-assertion-dynamically/60063/3 "2021-03-29T19:46:22Z")

</div>

Hi @ashuotosh.syn,

Welcome to the Community!

> [@ashuotosh.syn](#):
>
> What we are looking for an REST API to call to get the JWT token.

Are you looking for the [ID Token](https://auth0.com/docs/tokens/id-tokens) or an [Access Token](https://auth0.com/docs/tokens/access-tokens)? ID Tokens are always JWTs, however, Access Tokens can be opaque or a JWT depending on the audience.

The example looks like an Access Token, but it sounds like you are wanting user data.

You can use the Management API’s [GET](https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id)[/api/v2/users/{id}](https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id) endpoint to get user data. In order to make the request, you’ll need to get a Management API Access Token which you can see how to do here:

> **[Management API Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/management-api-access-tokens)**
>
> Learn how Auth0 Management APIv2 Access Tokens work and how to use them.

---

<div class="post-metadata">

**Author:** ![ashuotosh.syn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ashuotosh.syn/32/14581_2.png) [@ashuotosh.syn](https://community.auth0.com/u/ashuotosh.syn)\
**Post date:** [April 5, 2021, 5:43pm UTC](https://community.auth0.com/t/rest-api-to-get-jwt-user-assertion-dynamically/60063/4 "2021-04-05T17:43:40Z")

</div>

This is not what we are looking for. We looking for some api which can be called with the payload, private key and generate the JWT user assertion token. The steps which we do manually to produce from webui. Can we join a short call just to explain. This will add much more value to what we have here.

HEADER:  
{“alg”: “RS256”,  
“typ”: “JWT”,  
“kid”: “”  
}  
PAYLOAD:  
{  
“sub”: " ",  
“jti”: " ", ---- Any ID  
“iat”: 1616667714,  
“exp”: 1616807714,  
“iss”: " ", — Client ID  
“aud”: “[https://identity.oraclecloud.com/”](https://identity.oraclecloud.com/%E2%80%9D)  
}

Thanks!

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [April 6, 2021, 7:47pm UTC](https://community.auth0.com/t/rest-api-to-get-jwt-user-assertion-dynamically/60063/5 "2021-04-06T19:47:00Z")

</div>

If you need to receive an Access Token via API call without a webui or user interaction, then it sounds like you may want to set up a [Machine-to-Machine Application](https://auth0.com/docs/quickstart/backend) and use [client credentials flow](https://auth0.com/docs/flows/client-credentials-flow).

The API request would look like this:

```auto
curl --request POST \
  --url 'https://YOUR_DOMAIN/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=client_credentials \
  --data client_id=YOUR_CLIENT_ID \
  --data client_secret=YOUR_CLIENT_SECRET \
  --data audience=YOUR_API_IDENTIFIER

```

You can read more about implementing client credentials flow here:  
[https://auth0.com/docs/flows/call-your-api-using-the-client-credentials-flow](https://auth0.com/docs/flows/call-your-api-using-the-client-credentials-flow)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 21, 2021, 7:47pm UTC](https://community.auth0.com/t/rest-api-to-get-jwt-user-assertion-dynamically/60063/6 "2021-04-21T19:47:15Z")

</div>

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