How to edit the oktacallback component

Hello,
Documentation on oktacallbackcomponent states that : " This logic can be customized by copying the component to your own source tree and modified as needed. For example, you may want to capture or display errors differently or provide a helpful link for your users in case they encounter an error on the callback route. The most common error is the user does not have permission to access the application. In this case, they may be able to contact an administrator to obtain access."

This is exactly what I would like to do but Iā€™m unsure which files I need to edite in the node_modules or if there is a better approach

Has anyone ran into the same issue before?

Just trying to display and give the user options when I get the error ā€œuser does not have permission to access the applicationā€

Thanks

Which SDK are you using, is it the React SDK which supports creating a custom callback component?

Sorry should have mentioned that it is the angular sdk

Hey there! To create your callback component, the best way is to copy the code from the implementation in the SDK found in this file into a component you create within your project and edit it to your needs. In the route definition, youā€™ll add your custom component as the component for the callback route, for example:

const routes: Routes = [
  { path: 'login/callback', component: MyCustomCallbackComponent },
  ... remaining routes
];

Adding customization ability for the callback component in the Angular SDK is something weā€™re looking into, but it isnā€™t available yet.

Let us know how it goes and if you have any questions!

1 Like

Hello!

Thanks for the reply.

I started working on that approach and Iā€™m getting the following error.

These are my imports (I copied pasted the contents of the okta.config on the repo into my own okta.config file

Youā€™ll need to update your imports to import from the okta-angular module (unless your setup differs from what I imagine).

Youā€™ll need to change LOC 3 to

import { OKTA_CONFIG, OktaConfig, OKTA_AUTH } from '@okta/okta-angular';

I typed that out without trying in an IDE, so please shout out if you run into any troubles!

Hi, I initially had it set up that way, however Iā€™m still getting the same error.
Are there any extra files I need to import to my program? Pasting here my current set up of the callback component just in case.

import { Component, OnInit, Optional, Injector, Inject } from ā€˜@angular/coreā€™;
import { OktaAuth } from ā€˜@okta/okta-auth-jsā€™;
import { OktaAuthGuard } from ā€˜@okta/okta-angularā€™;
import { OKTA_CONFIG, OktaConfig, OKTA_AUTH } from ā€˜@okta/okta-angularā€™;

import { Component, OnInit, Optional, Injector, Inject } from ā€˜@angular/coreā€™;
import { OktaAuth } from ā€˜@okta/okta-auth-jsā€™;
import { OktaAuthGuard } from ā€˜@okta/okta-angularā€™;
import { OKTA_CONFIG, OktaConfig, OKTA_AUTH } from ā€˜@okta/okta-angularā€™;

What versions of the SDK are you using?
authClient.idx.isInteractionRequiredError(err) was added around okta-auth-js 6.7.

I still havenā€™t been able to get it working.
I have these two installed:

ā€œ@okta/okta-angularā€: ā€œ^6.1.0ā€,
ā€œ@okta/okta-auth-jsā€: ā€œ7.2.0ā€

Fyi, I was able to make it work. I commented out the portion of the code that was flagging it as an error. I might be missing something by doing that, but the code works after doing so. Im rolling with it.

const isInteractionRequiredError =
// this.oktaAuth.isInteractionRequiredError ||
this.oktaAuth.idx.isInteractionRequiredError;

thank you all so much for the help

1 Like

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