Get Header Authorization key in laravel controller?

Solution 1:

To get headers from the request you should use the Request class

public function yourControllerFunction(\Illuminate\Http\Request $request)
{
    $header = $request->header('Authorization');

    // do some stuff
}

See https://laravel.com/api/5.5/Illuminate/Http/Request.html#method_header

Solution 2:

Though it's an old topic, it might be useful for somebody...
In new Laravel versions, it's possible to get bearer Authorization token directly by calling Illuminate\Http\Request's bearerToken() method:

Auth::viaRequest('costom-token', function (Request $request) {
    $token = $request->bearerToken();
    // ...
});

Or directly from a controller:

public function index(Request $request) {
    Log::info($request->bearerToken());
    // ...
}