I am using session authentication with the following Angular 2 service method.
login(username : string, password : string) {
var data = {
username: username,
password: password
}
return this.http.post(environment.apiEndpoint + 'login', data)
.catch((error) => {
return Observable.throw(error.json());
});
}
Result : Response contains csrftoken and sessionid in the header setcookie value but it's ignored by angular.
Adding with credentials causes CSRF invalid token error.
How to login using Angular 2 and Django rest framework with session authentication scheme ? Thnx in advance!