Accessing id_token in expressjs

I am writing a new expressjs app in node. I have implemneted auth using auth0 and the implicit post form flow.

When I access the session data from express for each request, I notice no id_token. I realize now that auth0 stores that information in its own cookie. How do I retrieve that cookie so I can grab the id_token?

My goal is to get the email address of the user and use it in a datbase lookup in the app for each request. AM I thinking about this wrong?

Hi @ed.thompson,

Have you made sure to pass in the response_type=id_token and scope=openid in your login request?

For example:

https://{yourDomain}/authorize?
    response_type=id_token token&
    response_mode=form_post&
    client_id={yourClientId}&
    redirect_uri={https://yourApp/callback}&
    scope=openid%20name%20picture&
    state=STATE&
    nonce=NONCE

Thanks,
Rueben

Yes.

To clrify, the id_token is passed back, I just don’t know how to get to it.

Assuming you are using the express-openid-connect module, you should be able to get the ID Token with req.oidc.idToken. RequestContext | express-openid-connect

1 Like