Error after upgrading to latest version: AuthSdkError: Passed in oktaAuth is not compatible with the SDK, minimum supported okta-auth-js version is 5.3.1

Hi,
We had to work on new laptop and upgrade the versions. I am using okta-auth-js of 7.5.1 but I am seeing error; “main.js:1 ERROR AuthSdkError: Passed in oktaAuth is not compatible with the SDK, minimum supported okta-auth-js version is 5.3.1.”
How is this even possible? I am using 7.5.1 and its saying minimum is 5.3.1. It is higher than the version mentioned. can you please help?

Below is the configuration in package.json:
“angular/animations”: “^17.1.3”,
“angular/common”: “^17.1.3”,
“angular/compiler”: “^17.0.0”,
“angular/core”: “^17.1.3”,
“angular/flex-layout”: “^15.0.0-beta.42”,
“angular/forms”: “^17.1.3”,
“angular/material”: “^17.1.2”,
“angular/platform-browser”: “^17.1.3”,
“angular/platform-browser-dynamic”: “^17.1.3”,
“angular/platform-server”: “^17.1.3”,
“angular/router”: “^17.1.3”,
“okta/okta-angular”: “^6.3.2”,
“okta/okta-auth-js”: “^7.5.1”,
“okta/okta-signin-widget”: “^7.15.1”,
“types/jquery”: “^3.5.29”,
“aws-sdk”: “^2.1557.0”,
“bootstrap”: “^5.2.3”,
“jquery”: “^3.6.4”,
“jwt-decode”: “^4.0.0”,
“linqts”: “^1.15.0”,
“lodash”: “^4.17.21”,
“oidc-client”: “^1.11.5”,
“popper.js”: “^1.16.0”,
“run-script-os”: “^1.1.6”,
“rxjs”: “~7.8.1”,
“tslib”: “^2.5.0”,
“zone.js”: “~0.14.4”

Hi there @rnataraj !

Welcome to the community! This error might have something to do with how you are calling the oktaAuth service. In okta-angular v5, the passed in oktaAuth utilizes an injection token like this:

import { Component, Inject, OnInit } from '@angular/core';
import { OKTA_AUTH } from '@okta/okta-angular';
import { OktaAuth } from '@okta/okta-auth-js';

@Component({
  selector: 'app-component',
  template: `
    <pre id="userinfo-container">{{ user }}</pre>
  `,
})
export class MyProtectedComponent implements OnInit {
  user: string = '';
  constructor(@Inject(OKTA_AUTH) private oktaAuth: OktaAuth) {}
  
  async ngOnInit() {
    const user = await this.oktaAuth.getUser();
    this.user = JSON.stringify(user, null, 4);
  }
}

If it helps, here’s an example of an Angular project using versions more closely aligned with yours. I just verified it runs if I update the okta-auth-js version to the latest.

Let us know how it goes!

Thanks for the sample Code.
Let me try it out and shall update

Hi @alisaduncan , I am facing similar error. And using okta sign in widget of our company in our application. And
I tried to incorporate the way okta is being called now. I pasted my code for reference. Can you please take a look and let us know what might be going wrong for okta to be throwing error? Using latest okta versions…

below is app.component.ts:
export class AppComponent implements OnInit {
public isAuthenticated$!: Observable;
private oktaStateService = inject(OktaAuthStateService);
private oktaAuth = inject(OKTA_AUTH);
public ngOnInit(): void {
this.isAuthenticated$ = this.oktaStateService.authState$.pipe(
filter((s: AuthState) => !!s),
map((s: AuthState) => s.isAuthenticated ?? false)
);
}

public async signIn(): Promise {
await this.oktaAuth.signInWithRedirect();
}

public async signOut(): Promise {
await this.oktaAuth.signOut();
}
}
And here is app.module.ts:
const oktaConfig: OktaAuthOptions = {
scopes: [‘profile’, ‘openid’, ‘groups’, ‘email’]

};

@NgModule({
declarations: [
AppComponent,
HomeComponent,
LoginComponent,
HeaderComponent,
FooterComponent,
ThankyouComponent
],
imports: [
BrowserModule,
HttpClientModule,
BrowserAnimationsModule,
FlexLayoutModule,
MatToolbarModule,
MatMenuModule,
MatIconModule,
MatCardModule,
MatButtonModule,
MatTableModule,
MatDividerModule,
AppRoutingModule,
OktaAuthModule,
MatFormFieldModule,
FormsModule,
MatInputModule,
MatOptionModule,
MatSelectModule,
MatSlideToggleModule,
MatProgressSpinnerModule,
MatSortModule,
MatPaginatorModule,
ReactiveFormsModule,
MatNativeDateModule,
MatRadioModule,
MatTooltipModule,
MatSelectModule,
MatSortModule,
MatTabsModule,
MatDialogModule,
MatDatepickerModule,
MatCheckboxModule
],
providers:
[
{ provide: OKTA_CONFIG, useValue: { oktaAuth: oktaConfig } }
],
bootstrap: [AppComponent]
})
export class AppModule {
}
and below is login.component.ts:
export class LoginComponent implements OnInit {
widget = new OktaSignIn({
scopes: [‘profile’, ‘openid’, ‘groups’, ‘email’]
});
isAuthenticated = false;
constructor(@Inject(OKTA_AUTH) public oktaAuth: OktaAuth, private authStateService: OktaAuthStateService, private router: Router) {
if (this.isAuthenticated) {
this.router.navigate([‘/home’]);
}
// Show the widget when prompted, otherwise remove it from the DOM.
router.events.forEach(event => {
if (event instanceof NavigationStart) {
switch (event.url) {
case ‘/login’:
break;
default:
this.widget.remove();
break;
}
}
});
}
ngOnInit(): void {
if (this.isAuthenticated) {
this.router.navigate([‘/home’]);
}
this.widget.showSignInToGetTokens({
el: ‘#okta-signin-container
}).then(async (tokens: Tokens | undefined) => {
const originalUri = this.oktaAuth.getOriginalUri();
if (originalUri === DEFAULT_ORIGINAL_URI) {
this.oktaAuth.setOriginalUri(‘/’);
}
await this.oktaAuth.signInWithRedirect().then(
_ => this.router.navigate([‘/home’])
);
}).catch((err: any) => {
// Typically due to misconfiguration
throw err;
});
}
}

Hey there @pmoda !

I’m sorry to hear you’re seeing this error. I haven’t worked on code using the Okta sign-in widget in a while, so I think your best bet is to check out the samples. Have you tried comparing your code to this one?

Let us know how it goes!

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