I have some code which needs to read the contents of a JWT token.
var handler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler();
var token = handler.ReadJwtToken(secret);
When debugging I can observe the secret
to have the following payload:
{
"iss": "https://my.site.com/trust",
"nbf": 1714558573,
"iat": 1714558573,
"exp": 1714562173,
"aud": "https://api.site.com",
"scope": [
"openid",
"profile",
"offline_access"
],
"amr": [
"asos"
],
"client_id": "TestClient",
"sub": "125",
"auth_time": 1714558568,
"idp": "site",
"sid": "BC8DAC5545656C7E022F20B08D45BC56",
"aid": "anonymousId60c95f5b-8b71-47a1-af7f-fc5e34f573ae",
"sess": "sessionId3820377f-b412-4938-8f47-31d37b663a17",
"cgd": "57f60f1e-02ad-4a90-a728-9b5e6ea5e263",
"jti": "05093E7CEBC67C601C4DDC90B6C34FB9"
}
However, observing the token
variable shows it only contains the following claims:
"iss: https://my.site.com/trust"
"iat: 1714558573"
"aud: https://api.site.com"
"amr: asos"
"sub: 125"
"idp: site"
"aid: anonymousId60c95f5b-8b71-47a1-af7f-fc5e34f573ae"
"cgd: 57f60f1e-02ad-4a90-a728-9b5e6ea5e263"
"jti: 05093E7CEBC67C601C4DDC90B6C34FB9"
This list seems pretty random to me – some are well-known JWT claims whereas others are my custom claims. But other claims from my payload are omitted entirely.
How can I make JwtSecurityTokenHandler
build a complete list of claims from my token?