Getting the id_token programmatically

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:

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?

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:

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 documentation helpful.

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

Thank you.