How to Logout User from API with Laravel Passport

Hello Artisan,

In this tutorial, I will show you how to logout a user from API in Laravel using passport authentication. I will show you the source code of logging out a user from api if you use Laravel passport.

Laravel passport provides a revoke() method and using that method we can easily logout a user from passport based api. So see the below example of how we can logout a user from api.

public function logout()

    return response()->json([
        'message' => 'Successfully logged out'


Read also: Upload Large CSV File using Queue Job Batching in Laravel


Hope it can help you.


Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js