The bearerToken()
function is very handy when you are working with apis & want to access the token from Authorization header.
1// Don't parse API headers manually like this:2$tokenWithBearer = $request->header('Authorization');3$token = substr($tokenWithBearer, 7);4 5//Do this instead:6$token = $request->bearerToken();
Tip given by @iamharis010