Pass token from afterCallback to returnTo URL

When using openid-express-connect, I have access to the JWT token in the custom afterCallback method I implemented.

How do I pass this token to the returnTo url as a query parameter? The returnTo URL is specified during login:

res.oidc.login({
    returnTo: "https://example.com",
  });

I want it to be: https://example.com?token=TheTokenIGotFromAfterCallback

Is this possible?

I figured this out. The third parameter to afterCallback() is a the decoded state object. It has the returnTo value which can be modified.

1 Like