<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D51Y00006jOfA6SAKOkta Classic EngineLifecycle ManagementAnswered2020-07-30T00:48:41.000Z2019-10-07T16:13:45.000Z2019-10-08T22:21:57.000Z
OktaAuthService.loginRedirect() does not bring up Okta login screen

I'm following the [quickstart guide](https://developer.okta.com/quickstart/*/angular/nodejs/express) for `okta-angular` to integrate Okta Auth into my existing app.

 

 

 

I initiate the login, at `localhost:{port}/login`. no errors occur. this is where I think I'm supposed to be redirected to Okta's authentication screen where I could theoretically authenticate, but instead I am redirected to `localhost:{port}/implicit/callback`. at this point the guide kind of stops and moves on to building a NodeJS server, so I'm not sure what the expected behavior is or anything.

 

 

**The Code

here is the code, with irrelevant bits removed:

 

 

***app.module.ts

I import all my app's routes, including the one for `OktaCallbackComponent`...

```

// where the OktaCallback route is defined:

 

import { RoutesModule } from './routes/routes.module';

import { NgModule } from '@angular/core';

 

@NgModule({

  imports: [

    RoutesModule,

```

 

***routes.ts

I define all my app's routes...

```

import { OktaCallbackComponent } from '@okta/okta-angular';

 

export const routes = [

  { path: 'implicit/callback', component: OktaCallbackComponent },

```

 

***routes.module.ts

I create a separate Module for my routes to be imported into my main AppModule...

```

import { routes } from './routes';

import { RouterModule } from '@angular/router';

import { NgModule } from '@angular/core';

import { OktaAuthModule } from '@okta/okta-angular';

 

const config = {

  issuer: 'https://{my-domain}/oauth2/default',

  redirectUri: 'http://localhost:{port}/implicit/callback',

  clientId: wouldn't you like to know ;),

  pkce: true,

};

 

@NgModule({

  imports: [

    OktaAuthModule.initAuth(config),

    RouterModule.forRoot(routes, { enableTracing: false }),

  ],

````

 

***login.component.ts

```

import { OktaAuthService } from '@okta/okta-angular';

 

@Component({

  selector: 'app-login',

  templateUrl: './login.component.html',

  styleUrls: ['./login.component.scss'],

})

export class LoginComponent implements OnInit, OnDestroy {

  isAuthenticated: boolean;

 

  constructor(public oktaAuth: OktaAuthService) {

    this.oktaAuth.$authenticationState.subscribe(

      (isAuth: boolean) => this.isAuthenticated = isAuth,

    );

  }

 

  async ngOnInit() {

    this.isAuthenticated = await this.oktaAuth.isAuthenticated();

  }

 

  login() {

    this.oktaAuth.loginRedirect('/home');

  }

 

  logout() {

    this.oktaAuth.logout('/');

  }

```

 

there's a good chance I simply configured this wrong. the only difference between the Angular Quickstart guide and mine is the OktaAuthService is defined and used in my Login Component as opposed to App Component, and my logout function redirects to /home.


  • Hi Lane,

     

    Thank you for posting!

     

    I wanted to let you know that we have resources available specifically for developers at https://developer.okta.com, including a Developer Forum (https://devforum.okta.com/) and documentation. If you are unable to find the solutions you're looking for there, we would encourage you to contact our dedicated Developer Support team at developers [at] okta [dot] com, and they will be able to help you out.

     

    -----

    Tim Lopez

    Manager, Social Media Customer Support

    Okta Inc

     

    Follow @OktaSupport on Twitter!

     

    Expand Post
    Selected as Best
  • Hi Lane,

     

    Thank you for posting!

     

    I wanted to let you know that we have resources available specifically for developers at https://developer.okta.com, including a Developer Forum (https://devforum.okta.com/) and documentation. If you are unable to find the solutions you're looking for there, we would encourage you to contact our dedicated Developer Support team at developers [at] okta [dot] com, and they will be able to help you out.

     

    -----

    Tim Lopez

    Manager, Social Media Customer Support

    Okta Inc

     

    Follow @OktaSupport on Twitter!

     

    Expand Post
    Selected as Best
This question is closed.
Loading
OktaAuthService.loginRedirect() does not bring up Okta login screen