I am able to successfully login to an api and return a JWT with the following:
login(credentials) {
let json = JSON.stringify({ username: ‘someuser’, password: “somepass” });
let headers = new Headers({ ‘Content-Type’: ‘application/json’ });
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
this.authHttp.post(this.LOGIN_URL, json, options)
.map(res => res.json())
.subscribe(
data => {
if (data.id_token) {
this.local.set('id_token', token);
this.user = this.jwtHelper.decodeToken(token).username;
}
resolve(data);
},
err => {
this.error = err;
reject(err)
}
);
});
}
However, I cannot seem to pass the token back to the api for any further calls.
This used to work before RC0:
getPostLoginData(property): Observable<Object> {
let json = JSON.stringify({ extradata: 'somdata' });
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.authHttp.post(this.appURL + "api/protected/getmoredata", json, options)
.map(res => res.json())
.catch(this.handleError);
}
Do I need to pass the token in the headers? Or is this handled in authHttp?