Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ahoi's avatar
Level 5

Laravel Spark with Passport

Hello everybody,

I am using Laravel Passport to authenticate my VueJS-SPA, which works fine :-)

Now I'd like to implement Laravel Spark - but unfortunately Spark does not work out of the box with Passport.

If I set the required middleware to the default values like this:

    'middleware' => ['web', 'auth'],

the user is being redirected to the login page instantly.

Well - I tried to set it to

    'middleware' => ['api', 'auth:api'],

but this leads to the very same problem.

Setting

    'middleware' => ['api'],

solves the problem - but the error is being replaced by

ErrorException Attempt to read property "profile_photo_url" on null

which points to

            'userAvatar' => Auth::user()->profile_photo_url,

in vendor/laravel/spark-stripe/src/FrontendState.php:66.

Auth::user() is indeed null, which I checked in SparkServiceProvider.php inside the authorize-method:

 Spark::billable(Team::class)->authorize(function (Team $billable, Request $request) {
            ray($request->user());
            ray(Auth::user());
        });

Any thoughts on that?

0 likes
1 reply
ahoi's avatar
Level 5

Seems like this is not possible at all with spark.

I switched to Sanctum, which works fine here.

Please or to participate in this conversation.