You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In v3 of the library, you could get the access token scopes from session.accessTokenScope. In v4, there doesn't seem to be any way to access the access token's scopes, or even to decode the access token at all. Is there a recommended way to do this?
Describe the ideal solution
The library should provide the access token's scopes like it did before, and/or provide the whole decoded access token, or a way to decode it.
Alternatives and current workarounds
Currently I am working around this by decoding the access token using jose, in the same way the library's internal AuthClient does it. I want to use the same jwksCache though, and it isn't exposed by the library, so I have to cast to unknown in order to access it, which isn't ideal.
import*asjosefrom"jose";importauth0from"./auth0.ts";constISSUER=`https://${process.env.AUTH0_DOMAIN}/`;constJWKS_URI=`${ISSUER}.well-known/jwks.json`;typeTokenWithScope=jose.JWTPayload&{scope: string};exportasyncfunctiondecodeAccessToken(accessToken: string): Promise<TokenWithScope>{// Auth0 does not expose the authClient, so we need to cast to a type that exposes the jwksCacheconstjwksCache=(auth0asunknownas{authClient: {jwksCache: jose.JWKSCacheInput}}).authClient.jwksCache;constkeyInput=jose.createRemoteJWKSet(newURL(JWKS_URI),{[jose.jwksCache]: jwksCache});const{ payload }=awaitjose.jwtVerify<TokenWithScope>(accessToken,keyInput,{issuer: ISSUER,audience: process.env.AUTH0_AUDIENCE,algorithms: ["RS256"],});returnpayload;}
Additional context
No response
The text was updated successfully, but these errors were encountered:
Checklist
Describe the problem you'd like to have solved
In v3 of the library, you could get the access token scopes from
session.accessTokenScope
. In v4, there doesn't seem to be any way to access the access token's scopes, or even to decode the access token at all. Is there a recommended way to do this?Describe the ideal solution
The library should provide the access token's scopes like it did before, and/or provide the whole decoded access token, or a way to decode it.
Alternatives and current workarounds
Currently I am working around this by decoding the access token using
jose
, in the same way the library's internalAuthClient
does it. I want to use the samejwksCache
though, and it isn't exposed by the library, so I have to cast tounknown
in order to access it, which isn't ideal.Additional context
No response
The text was updated successfully, but these errors were encountered: