grumar / adal-angular5

Angular 5 ADAL Wrapper
MIT License
12 stars 19 forks source link

Get Token http error #4

Closed chigivigi closed 6 years ago

chigivigi commented 6 years ago

I am working in a single page application in which i trying to get token from my backend application. I have followed the example on this site https://github.com/benbaran/adal-angular4-example to initialize the authentication. Immediately after the application is authorized I am calling my service to acquire token for my backend application but I receive the error for my service:

[AuthService -> Http]: NullInjectorError: No provider for Http!

In the service I call a method that calls Adal5Service acquireToken method. Is there a way to call the acquire token method without triggering the error ?

I am working in angular version 5.20.

grumar commented 6 years ago

Probably this is because You're providing AdalAngular5 in this way:

providers: [
        Adal5Service,
        { provide: Adal5HTTPService, useFactory: Adal5HTTPService.factory, deps: [Http, Adal5Service] } 
  ]

but You should:

providers: [
        Adal5Service,
        { provide: Adal5HTTPService, useFactory: Adal5HTTPService.factory, deps: [HttpClient, Adal5Service] } 
  ]

different deps HttpClient instead of Http

I added example in Readme

chigivigi commented 6 years ago

I changed http to httpclient in my application and it stills does not work. Can it be something else ?