kinde-oss / kinde-auth-react

Kinde React SDK for frontend authentication flows
https://kinde.com/docs/developer-tools/react-sdk/
MIT License
50 stars 11 forks source link

Add getIdToken method #38

Closed mchr3k closed 7 months ago

mchr3k commented 9 months ago

Explain your changes

I've raised a support thread in Discord: https://discord.com/channels/1070212618549219328/1179456563627438141

[...]can you help me understand how to use and validate the ID Token (https://kinde.com/docs/build/about-id-tokens/) ? I'm already passing the Access Token to my REST API through the "authorization" HTTP header. However, this token doesn't contain the user's email address (https://kinde.com/docs/build/about-access-tokens/) and so on every REST API call I'm currently getting a M2M token and calling the Kinde API to get the user object to get their email address. The ID token includes the user's email address (https://kinde.com/docs/build/about-id-tokens/) but I can't see any example in your docs of the recommended way of passing this token through to a REST API and validate serverside that the ID token is valid.

This PR exposes the getIdToken() method which I've proposed adding in https://github.com/kinde-oss/kinde-auth-pkce-js/pull/57

Checklist

🛟 If you need help, consider asking for advice over in the Kinde community.

greg-atomic commented 7 months ago

FYI: In order to be able use Kinde with an identity provider on AWS, I also need the raw identity token. This PR is essential for that.

DaveOrDead commented 7 months ago

@greg-atomic this should now be available in v3.0.26