Sign-in widget redirects to okta main login page

I’m using the sign-in widget for my app. After I log in with the widget rather than take me to the app it takes me to the okta main login page forcing me to login twice before taking me to the app. What could be responsible for this?

The only thing I can think of is you’re not setting the redirectUri to come back to your app. See the following documentation for more details:

https://developer.okta.com/code/javascript/okta_sign-in_widget#sign-in-to-your-application

@mraible Thanks for the quick response! I think I did unless there is something else I should have done see my code below:

const oktaConfig = {
    issuer: '{issuer}',
    clientId: '{clientId}',
    redirectUri: 'http://localhost:4200/implicit/callback',
    scope: 'openid profile email'
}
....
OktaAuthModule.initAuth(oktaConfig)

And then in my login page I have this:

signIn = new OktaSignIn({baseUrl: '{orgUrl}'});
async ngOnInit() {
    this.isAuthenticated = await this.oktaService.isAuthenticated();
    
    this.signIn.renderEl({el: '#okta-signin-container'}, (response) => {
        if(response.status === 'SUCCESS'){
            this.oktaService.loginRedirect('/', { sessionToken: response.sessionToken});
        }
    },
    (err) => {
        throw err;
    });
}

It looks like you’re trying to use our Angular SDK and the Sign-In Widget. I’d suggest checking out our Angular samples, specifically the “custom login page” sample. I’d also recommend looking at the Okta-hosted Login sample since then you don’t need to worry about configuring the Sign-In Widget.

@mraible Thanks! Your samples gave me a clue to what was missing. I added clientId and redirectUri to the sign-in widget also like so:

signIn = new OktaSignIn({
            baseUrl: '{orgUrl}',
            clientId: '{clientId}',
            redirectUri: '{redirectUri}'
        });

It is okay now. Thanks!

1 Like