Well, I don't if it is the best solution for this problem, but I created a middleware to fetch the user if any token if provided in the request headers. Solved the problem for me. ;) If any one have a better solution, please, be free to recomend it...
<?php
namespace App\Http\Middleware;
use App\Models\User;
use Closure;
class FetchUserByBearerToken
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$bearerToken = $request->bearerToken();
if ($bearerToken) {
$user = User::firstWhere('api_token', '=', $bearerToken);
\Auth::login($user);
}
return $next($request);
}
}