0

I've built a webapp using ionic. I'm trying to import the MSALModule into my app. According to the tutorials etc I've found online, you have to add following to app module :

MsalModule.forRoot({
      clientID: OAuthSettings.appId
    }),

currently its giving me the following error when I try to go to the page where it is used.

We have a generic Error:  Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[MsalGuard -> Router]: 
  StaticInjectorError(Platform: core)[MsalGuard -> Router]: 
    NullInjectorError: No provider for Router!
Error: StaticInjectorError(AppModule)[MsalGuard -> Router]: 
  StaticInjectorError(Platform: core)[MsalGuard -> Router]: 
    NullInjectorError: No provider for Router!
    at _NullInjector.get (core.js:994)
    at resolveToken (core.js:1292)
    at tryResolveToken (core.js:1234)
    at StaticInjector.get (core.js:1102)
    at resolveToken (core.js:1292)
    at tryResolveToken (core.js:1234)
    at StaticInjector.get (core.js:1102)
    at resolveNgModuleDep (core.js:10847)
    at _createClass (core.js:10888)
    at _createProviderInstance$1 (core.js:10858)
    at c (polyfills.js:3)
    at Object.reject (polyfills.js:3)
    at NavControllerBase._fireError (nav-controller-base.js:223)
    at NavControllerBase._failed (nav-controller-base.js:216)
    at nav-controller-base.js:263
    at t.invoke (polyfills.js:3)
    at Object.onInvoke (core.js:4733)
    at t.invoke (polyfills.js:3)
    at r.run (polyfills.js:3)
    at polyfills.js:3

I don't have the routing module imported cos i'm not using angular (or ionic) routing in the app. Is there a way to get rid of this error without using routing? i.e. can I use MSAL without setting up routing in my app?

1 Answers1

1

I see you have the import statement...did you add to the Providers section:

{ provide: HTTP_INTERCEPTORS, useClass: MsalInterceptor, multi: true }

My understanding is it is not absolutely necessary, as long as you have a custom provider that you have developed. But, if that doesn't exist, you need to have this in your providers section.

Briana Finney
  • 1,171
  • 5
  • 12
  • 22