I am trying to get the authorization token being sent by angular to php. My angular intercepter looks as follows
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (localStorage.getItem('token') != null) {
const clonedReq = req.clone({
headers: req.headers.set('Authorization', 'Bearer ' + localStorage.getItem('token'))
});
return next.handle(clonedReq).pipe(
tap(
succ => { },
err => {
if (err.status == 401){
localStorage.removeItem('token');
localStorage.removeItem('username');
this.router.navigateByUrl('/user/login');
}
}
)
)
}
else {
return next.handle(req.clone());
}
}
I console logged the request to see the output and it has the token.
Then i went to Network tab of developer tools to see if token was in the request and it was there.
Now how do I get the token in php? I tried following the answer to this question. But that doesn't help either. Following is the output when using the code in above answer.