In the AuthServiceProvider;
Auth::viaRequest('api', function ($request) {
if ($request->input('api_token')) {
return User::where('api_token', $request->input('api_token'))->first();
}
});
I can't seem to get this to work. GET
requests do not have a body
so no input
is present.
Also I've tried using $request->header('api_token')
but still getting unauthorised
If I do an independent search on the DB
like below it works;
Auth::viaRequest('api', function ($request) {
return User::where('api_token', 'my_api_key')->first();
});
Can anyone confirm that the $request
header can be accessed here?