authts / oidc-client-ts

OpenID Connect (OIDC) and OAuth2 protocol support for browser-based JavaScript applications
https://authts.github.io/oidc-client-ts/
Apache License 2.0
1.38k stars 207 forks source link

Does the library access AccessToken claims data? #1280

Open FinHorsley opened 11 months ago

FinHorsley commented 11 months ago

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

pamapa commented 11 months ago

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 =...

paulsancer commented 7 months ago

@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!