I have a login service in odoo, which gives token in header response of login request. The subsequent requests require that token in headers only after that it will be authorized.
How can i access that token so that after saving it can be sent in next requests ?
Below is my tried code which doesn't work.
var headers = new HttpHeaders();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json' );
headers.append('');
this.testResp = this.httpClient.post(this.serverURL,this.postParam,{ headers: headers })
.subscribe(data => {
console.log(data['_body']);
}, error => {
console.log(error);
});
Below is the postman request which gives me token in response header session-id
in Set-Cookie
.
Followed solution mentioned in this link but still it does not giving the expected result.
Here is updated code
var headers = new HttpHeaders();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json' );
const options = {
headers: headers,
observe: "response" as 'body', // to display the full response & as 'body' for type cast
responseType: "json"
};
this.testResp = this.httpClient.post(this.serverURL, this.postParam, {headers: headers, observe: "response"})
.subscribe(response => {
console.log(response.headers.has("Set-Cookie"));
return response;
}, err => {
throw err;
});