# Getting the id\_token programmatically

**URL:** <https://community.auth0.com/t/getting-the-id-token-programmatically/72765>\
**Category:** Get Help\
**Tags:** jwt\
**Created:** [November 8, 2021, 3:17pm UTC](https://community.auth0.com/t/getting-the-id-token-programmatically/72765 "2021-11-08T15:17:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddelizia](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ddelizia/32/32839_2.png) [@ddelizia](https://community.auth0.com/u/ddelizia)\
**Post date:** [November 8, 2021, 3:17pm UTC](https://community.auth0.com/t/getting-the-id-token-programmatically/72765/1 "2021-11-08T15:17:06Z")

</div>

I am in the process of building my api integration test which rely on idToken (with all user details). Is there any way to get the jwt programmatically?

At the moment I am able to get only the access\_token calling `/oauth/token` endpoint:

```auto
curl --request POST \
  --url 'https://xxxx.auth0.com/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=password \
  --data username=xxx@xxx.xx \
  --data password=xxxxx \
  --data 'audience=https://xxxxx' \
  --data scope=read:sample \
  --data 'client_id=xxxxxx' \
  --data 'client_secret=xxxxxxx'`

```

Is there any way to get the id\_token or maybe getting the id\_token with the access token?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 8, 2021, 8:25pm UTC](https://community.auth0.com/t/getting-the-id-token-programmatically/72765/3 "2021-11-08T20:25:37Z")

</div>

Hi @ddelizia,

Welcome to the Auth0 Community!

I understand that you’d like to get the id token with your request.

After looking at your code snippet, it appears that you are passing only the `read:sample` scope in your `/oauth/token` request which is for the access token.

In this case, I recommend that you pass at least the `openid` scope to your request to get the id\_token.

For example:

```auto
curl --request POST \
  --url 'https://YOUR_DOMAIN.auth0.com/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=password \
  --data username=user@example.com \
  --data password=pwd \
  --data audience=YOUR_API_IDENTIFIER \
  --data scope=openid profile email read:sample \
  --data 'client_id=YOUR_CLIENT_ID' \
  --data 'client_secret=YOUR_CLIENT_SECRET'

```

You may find our [OpenID Connect Scopes](https://auth0.com/docs/configure/apis/scopes/openid-connect-scopes) documentation helpful.

Please let me know if there are any other questions. I’d be happy to help.

Thank you.

---

<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:** [November 23, 2021, 8:26pm UTC](https://community.auth0.com/t/getting-the-id-token-programmatically/72765/4 "2021-11-23T20:26:07Z")

</div>

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