Dynamic redirectUri

In my Angular application, I am using @okta/okta-signin-widget with okta client id. My requirement is to use window.location.origin as redirect_uri.

import { NgModule } from ‘@angular/core’;
import { AppComponent } from ‘./app.component’;
import { RoutesModule } from ‘./routes/routes.module’;

import { OktaAuthModule } from ‘@okta/okta-angular’;

// Okta configuration
const oktaConfig = {
issuer: ‘https://dev-836625.oktapreview.com/oauth2/default’,
redirectUri: window.location.origin,
clientId: ‘xxxXXXxxXxxx’,
scope: ‘openid profile email’
};

@NgModule({
declarations: [
AppComponent
],
imports: [

OktaAuthModule.initAuth(oktaConfig),
RoutesModule,

providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

But after login, redirect_uri is returned as null. Please find the attachment

Help much appreciated!

Hi there, you need to register you redirect url in your app so if you want a dynamic redirect url then you will have to add all possible urls or update the app each time with the new url.

I am very beginner to OKTA, Could you please give me an example like how and where I can add all the URLs in the app

https://tools.ietf.org/html/draft-ietf-oauth-security-topics-13#section-3.1

You will need to gather the value of your redirect url (i’m not sure what the value of window.location.origin is but you will have to find out).

The go to your app and to the app’s general tab. You will then need to add the window.location.origin to the login redirect url.

I forgot to add but ensure it is 100% accurate down to the final ‘/’ as Okta will refuse anything that isn’t an exact match.