Get Bearer Token from Authorization header

The bearerToken() function is very handy when you are working with apis & want to access the token from Authorization header.

// Don't parse API headers manually like this:
$tokenWithBearer = $request->header('Authorization');
$token = substr($tokenWithBearer, 7);
 
//Do this instead:
$token = $request->bearerToken();

Tip given by @iamharis010

Recent New Courses