Search code examples
laraveloauth-2.0jwtlaravel-passport

How to verify a token with Laravel Passport?


I want to validate a token using Laravel Passport. My API's consumer will pass the token via the Authorization header as a Bearer token and I want that Laravel Passport returns me if is a valid token.

I don't want to use a middleware, my API will be in another Laravel Project, but I want this project to call the Laravel Passport server just for check if a token is valid, how can I check the token?

I'm issuing the tokens right, just left verify them, but I don't know how:(


Solution

  • This is how you can verify tokens without the middleware:

    Auth::guard('api')->check();