I'm struggling to integrate the angular2-jwt package. I've written the following function with custom configuration options
import { Http, Headers, RequestOptions } from '@angular/http';
import { provideAuth, AuthHttp, AuthConfig } from 'angular2-jwt';
import { Injectable } from '@angular/core';
export function authHttpServiceFactory(http: Http, options: RequestOptions) {
return new AuthHttp( new AuthConfig({
noTokenScheme: true,
tokenGetter: (() => JSON.parse( localStorage.getItem('access_token') ) ),
globalHeaders: [{'Accept': 'application/json'}],
}), this.http, this.options);
}
and inside my module definition I have included the lines
providers: [
...,
{
provide: AuthHttp,
useFactory: authHttpServiceFactory,
deps: [Http, RequestOptions]
}
],
but when I try to use AuthHttp inside a service it appears to ignore my factory method and returns a default implementation:
import { AuthHttp } from 'angular2-jwt';
@Injectable() export class SsoService {
constructor (
private authHttp: AuthHttp,
) {}
Is my module configuration correct? Have I missed something simple