Skip to content


How to get client id from a request in laravel passport?

Laravel1 min read


It’s a claim in JWT(RFC), just following to do

It’s good, but there are some problems with it 1. It’s optional in JWT. 2. You need to get it in middleware you making or controller.

jti(JWT ID)

As upon above, you can get it from jti, and validate it in the model.

The problems are the same as above, optional, and we got another problem, more query to the database.

Check client Credential

I think it the best way I’m knowing for now, overwrite Laravel\Passport\Http\Middleware\CheckClientCredentials , when the request is coming, set the client_id and passing next.

The PSR includes ServerRequest:

Next, Changing Kernel.php using instance, For per request, you can get client_id $request->get('client_id');

php - Laravel Passport Get Client ID By Access Token - Stack Overflow