Route [login] not defined. + laravel code example
Example 1: Route [login] not defined.Route [login] not defined.
Use Postman and set the Header `Accept: application/json` otherwise Laravel
Passport would never know it's an API client and thus redirect to a /login
page for the web.
Example 2: Route [login] not defined.Route [login] not defined.
To check either request includes token or not make your own middleware.
php artisan make:middleware CheckApiToken
public function handle($request, Closure $next)
{
if(!empty(trim($request->input('api_token')))){
$is_exists = User::where('id' , Auth::guard('api')->id())->exists();
if($is_exists){
return $next($request);
}
}
return response()->json('Invalid Token', 401);
}