Get authenticated user with Laravel Passport and grant password Get authenticated user with Laravel Passport and grant password php php

Get authenticated user with Laravel Passport and grant password


You forgot the appropriate middleware.

Route::get('/user', function(Request $request) {    return Auth::user();})->middleware('auth:api');

The authentication flow is not fired when you don't mention the auth middleware. That's why you get null.


I had the same problem with you. And i solved it after I manually defined the auth guard.

Route::get('/user', function (Request $request) {  return auth()->guard('api')->user();});


You need to pass the Access token back with every request. Please check the documentation for this part here