In my Node CLI I I use the auth0
package to call Auth0.
If I use the signIn method on the database login like this:
await this.authClient.database!.signIn({
username: email,
password,
connection: ‘Username-Password-Authentication’,
})
When I use this tool to decode the tool: https://jwt.io/
I get back a token which doesn’t contain the custom data I added via a rule, just the basic fields
{
“iss”: “https://mydomain.auth0.com/”,
“sub”: “auth0|5b6b2342j54355613fd40421”,
“aud”: “kcpmPE21Lc6nSJf36oneC5pxJ69Vs”,
“iat”: 1546061189,
“exp”: 1546097189
}
But when I use a password grant:
const asd = await this.authClient.oauth!.passwordGrant({username: email, password, realm: ‘Username-Password-Authentication’})
I get a token that decodes like this:
{
“https://www.mydomain.com/meta”: {
“roles”: [
“ordinary”
],
“importantValue”: “17”,
“claims”: [
“admin”
]
},
“nickname”: “piersm”,
“name”: “piers@piers.com”,
“picture”: “https://s.gravatar.com/avatar/74962f17942d8f13f13fde7af051eb90?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fpi.png”,
“updated_at”: “2018-12-29T05:26:30.034Z”,
“email”: “piers@piers.com”,
“email_verified”: false,
“iss”: “https://mydomain.auth0.com/”,
“sub”: “auth0|5b6b57f3e5439292923fd40421”,
“aud”: “kcpmPE21Lc6nSz5yFasateC5pxJ69Vs”,
“iat”: 1546061190,
“exp”: 1546097190
}
But I can’t specify the audience of that request so my backend API can’t decode the token.
I’m not sure I understand the difference of what I’m doing here that is causing this. Why are there different tokens? What’s the audience?