oidc-client-ts icon indicating copy to clipboard operation
oidc-client-ts copied to clipboard

Does the library access AccessToken claims data?

Open FinHorsley opened this issue 1 year ago • 2 comments

Apologies in advance if this has been answered before, I've had a good look through the existing docs/issues/prs but may have missed something!

Does the library expose any of the claims data from within the accessToken, or is it all provided by the idToken/userinfo endpoints? Looking at https://github.com/authts/oidc-client-ts/issues/477#issuecomment-1092505083, this suggests that it's only fetched from the id_token, but just wanted to double check.

Thanks 🙂

Edit: Found this from the oidc-client-js repo, basically just confirming if this library follows the same model? https://github.com/IdentityModel/oidc-client-js/issues/54

FinHorsley avatar Dec 04 '23 11:12 FinHorsley

Yes, it takes the claims from the id_token, you can see the affected code in the file https://github.com/authts/oidc-client-ts/blob/main/src/ResponseValidator.ts. Follow there response.profile =...

pamapa avatar Dec 04 '23 14:12 pamapa

@pamapa following up on this, I can't find a way to extend the type/interface of the profile object to include the claims that the token actually has and that i can see stored in local storage (ie employeeId in my usecase).

I've successfully done this with Express in the backend by extending the User interface like this:

declare namespace Express {
  interface User {
    ...
    employeeId: string;
    ....
  }
}

Maybe I am blind or looking at this at the wrong angle, but any help here would be appreciated, thanks!

paulsancer avatar Apr 03 '24 19:04 paulsancer