Kirby Kernen
Kirby Kernen

Reputation: 123

How to get successful API response NTLM Authorization?

I have an Angular 4 application which calls an API with NTLM Authentication. It returns 2 401's then the 200 response, however, the subscribed response in Angular returns undefined for the response, as it appears to get the first 401. In Fiddler I can see everything I need in the 200 response, but it is preceded by the two 401's. How do I get the 200 response data?

Service.ts

getCurrentUser(): Observable<any> {
    let options = new RequestOptions({ withCredentials: true });
    return this.http.get(urlBase, options)
        .map((response: any) => { return response.json() });
}

Component.ts

getUser() {
    let result: any;
    this._userService.getCurrentUser()
        .subscribe(
        data => result = data
        );
    console.log(result);
}

Fiddler: Fiddler response

Upvotes: 2

Views: 2693

Answers (1)

Kirby Kernen
Kirby Kernen

Reputation: 123

Turns out I was missing brackets around the this.result = data; It works now.

getUser() {
    this._userService.getCurrentUser()
        .subscribe(
            data => {
                this.result = data;
                console.log(this.result);
            });
};

Upvotes: 1

Related Questions