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

thamibn's avatar

Laravel Passport wrong expires in date

i am getting wrong expire in date, not sure why

"expires_in": "1970-01-01 23:59:59"

in my AuthServiceProvider i have this code


public function boot()
    {
        $this->registerPolicies();

        Passport::routes(function ($router) {
            $router->forAccessTokens();
            $router->forPersonalAccessTokens();
            $router->forTransientTokens();
        });
        Passport::tokensExpireIn(now()->addDay());
        Passport::refreshTokensExpireIn(now()->addDays(10));
    }

this is how i am getting it

'expires_in' => Carbon::parse($results->expires_in)->toDateTimeString(),

0 likes
2 replies
Nakov's avatar
Nakov
Best Answer
Level 73

@thamibn and based on the documentation:

The expires_in attribute contains the number of seconds until the access token expires.

So that's not the full date, but rather just seconds. So add the seconds to the date when the token was created and you will get the correct expires at time.

There was an issue regarding this long time ago, and it is answered the same as just I did: https://github.com/laravel/passport/issues/423#issuecomment-313962956

Please or to participate in this conversation.