Logged in User Details

I am trying to use nodejs sdk but there’s no API for getting logged user info - like email or name

Hello @mtwn105 while we don’t provide an endpoint to get that information directly, there’s a way to do it :wink:

If you use Hosted Auth to create a grant for a user, you can get the id_token parameter and simple base64 decode it.

If you follow this Quickstart guide Email API Quickstart: read and send email messages | Nylas Docs on the Receive a callback from Nylas with the user’s grant ID section you will need to get the id_token from the response variable. This variable is long so you will need a little regex to get just the part that you need…

^[^.]+

When you base64 decode that, you will have something like this:

{"alg":"HS256","typ":"JWT"}{"at_hash":"xxx","aud":"https://api.us.nylas.com/v3","email":"xxx@gmail.com","exp":1723894869,"family_name":"Tejada","given_name":"Alvaro","iat":xxx,"iss":"https://nylas.com","name":"Alvaro Tejada","picture":"https://lh3.googleusercontent.com/a/xxx","provider":"google","sub":"xxx-xxx-xxx-xxx-xxx"}