avital
November 27, 2023, 11:11am
1
Hey all,
I try to custom the : CallbackComponent (that Okta provide by default) .
I crated my custom CallbackComponent - CustomCallbackComponent
(copy it from your SDK implementation -
https://github.com/okta/okta-angular/blob/master/lib/src/okta/components/callback.component.ts )
In my logIn component I use :
await this.oktaAuth.signInWithRedirect({ originalUri: '/' });
I also update the routes:
const appRoutes: Routes = [
{
path: 'login/callback',
component: CustomCallbackComponent
},
{
path: '',
component: HomeComponent,
},
];
The problem is - when I inside CustomCallbackComponent, i dont get the token .
I would like to get your help with it…
thanks
erik
November 27, 2023, 11:18pm
2
Hello,
The Okta Callback Component either gets the tokens (implicit), or the code (authorization code) with this call,
constructor(
@Inject(OKTA_CONFIG) private config: OktaConfig,
@Inject(OKTA_AUTH) private oktaAuth: OktaAuth,
@Optional() private injector?: Injector
) {}
async ngOnInit(): Promise<void> {
try {
// Parse code or tokens from the URL, store tokens in the TokenManager, and redirect back to the originalUri
await this.oktaAuth.handleLoginRedirect();
} catch (e) {
// Callback from social IDP. Show custom login page to continue.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore Supports auth-js v5 & v6-7
const isInteractionRequiredError = this.oktaAuth.isInteractionRequiredError || this.oktaAuth.idx.isInteractionRequiredError;
if (isInteractionRequiredError(e) && this.injector) {
const { onAuthResume, onAuthRequired } = this.config;
const callbackFn = onAuthResume || onAuthRequired;
if (callbackFn) {
callbackFn(this.oktaAuth, this.injector);
Does your custom component still make this call?
Thank You,
To add to @erik 's response, can you provide some info on how you initialize the OktaAuthModule and your app setup? If you’re writing a NgModules application, can you provide your AppModule with your Okta config redacted (if defined there), or if you’re writing a stand-alone application, can you provide the app.config.ts (with redacted Okta config)?
There’s also a step to start the OktaAuth service that the Okta Angular SDK does as part of the OktaAuthModule setup, so I want to ensure all the pieces are there.