OktaAuthModule Not Resolving Correctly When Using Factory for Config (okta-angular and okta-auth.js)

Thanks Alisa… its working now… with
providers: [ {provide: OKTA_AUTH, useClass: AnyServiceWithOktaFunctions} ]

:slight_smile:

Great! Glad to hear it!

Hi Mraible,

The new problem, i m facing is related to
import

import { OKTA_AUTH } from '@okta/okta-angular';
import { OktaAuth } from '@okta/okta-auth-js';

constructor

constructor(
    @Inject(OKTA_AUTH) public oktaAuth: OktaAuth, 
    private router: Router) { }
async logout(){
    await this.oktaAuth.signOut({postLogoutRedirectUri: '/logged-out'});
  }

or


async logout(){
    await this.oktaAuth.signOut();
    this.router.navigateByUrl('/logged-out');
  }

SignOut function is accessing below url
Request URL: https://blablabla.okta.com/oauth2/ssdscrfbmulibdt/v1/revoke
Resulting CORS error now with signOut() but for earlier version it was working

Older version OktaAuthService

this.oktaAuthService.logout('/logged-out');

No CORS error with above code .

only i replaced the above line with signOut function in latest version of okta, it started giving CORS error for revoke.

Thanks
Gautam

The /revoke endpoint needs a Trusted Origin entry so that you can make CORS requests to it. Can you try adding your application URL to Trusted Origins (for CORS) and retry?

Sure, I will try and let you know. Thanks for the direction.

image
image
{ provide: OKTA_CONFIG, useValue: { OktaAuth: oktaConfig } },
I’m getting the above issue can you help me?

Hi Aravindhan, can try to replace OktaAuthOptions to OktaConfig only, hope that it can take okta interface.

Config

const oktaConfig: OktaConfig = {
    issuer: 'issuerlink',
    clientId: 'client-id',
    redirectUri: 'http://localhost:4200/callback'
  };
  const oktaConfig = new OktaAuth(oktaConfig);

Provider:

providers[
{ provide: OKTA_CONFIG, useValue: { oktaAuth : oktaConfig}}
]

Same issue I was getting earlier, where it is working for me now. You can check above.

Thanks
Gautam

what is the definition of oktaAuth and OktaConfig i’m not able to see any interface

Sorry, try removing interface

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