php - how to login the user with specific guard like api in laravel passport
one text
in my project i have a part that i want to manually logs in a user in my api guard , now what i have tried is that :
auth()->guard('api')->attempt($mobile,$password);
but i get this error :
"Method Illuminate\\Auth\\RequestGuard::attempt does not exist.", "exception": "BadMethodCallException", "
i tried to use :
$user = Auth::login($user);
but this logs the user in into web guard and not the api guard . another way i used the :
dd($user->createToken($user->name));
i have the token now and i wanted to know if its possible to logs the user into guard('api')
and have it authenticated . thanks in advance