Login redirect issue

Im Attemping to use the login through express, this is what I’ve added in server.js:
secret: secret,
resave: true,
saveUninitialized: false

var oktaDomain = “dev-05099272.okta.com”;
var client_id = “0oatj13yceIxzWd275d6”;

const oidc = new ExpressOIDC({
issuer: https://dev-______.okta.com/oauth2/default,
client_id: client_id,
client_secret: secret,
appBaseUrl: ‘http://localhost:7171’,
redirect_uri: ‘https://www.google.com’,
scope: ‘openid profile’

// ExpressOIDC attaches handlers for the /login and /authorization-code/callback routes

this is the error i get when being redirected to the login area:

Identity Provider: Unknown

Error Code: invalid_request

Description: The ‘redirect_uri’ parameter must be a Login redirect URI in the client app settings:’

What seems be the issue?

As Express is the one that should be handling the callback, the redirect_uri in your code should be set to the appropriate callback route in the app, which in this case looks like it should be http://localhost:7171/authorization-code/callback

You will then need to ALSO add the exact same URI as a Sign-in redirect URI in the application configuration in Okta.

If you make those changes, do you still see the same error?

1 Like

Works perfectly now, thank you

Would it be the same for signout?
I added the logout button and the parameter: post_logout_redirect_uri
I get this error:

Identity Provider:

Error Code: invalid_request

Description: The ‘post_logout_redirect_uri’ parameter must be a Logout redirect URI in the client app settings

How would I redirect the user to the login screen after logging out.

I believe by default the logout endpoint used by the SDK will be your appBaseUrl, so I would try setting it to that in the config and in Okta. That’s at least what our sample app does.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.