@hal.littel
To verify a token with Laravel Passport, you can use the Auth::user()
method which will return the currently authenticated user. Here is an example of how to verify a token with Laravel Passport:
- Ensure you have installed Laravel Passport by running php artisan passport:install.
- Create a route in your routes/api.php file to verify the token. For example:
1
2
3
|
Route::middleware('auth:api')->get('/user', function() {
return Auth::user();
});
|
- Make a request to the above route with the Authorization header containing the token. For example, using Postman:
- Set the request type to GET.
- Set the URL to http://your-app-url/api/user.
- Add a header with key Authorization and value Bearer YOUR_TOKEN_HERE.
- If the token is valid, the route will return the authenticated user in JSON format.
By following the above steps, you can verify a token with Laravel Passport and retrieve the authenticated user.