Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Personal Access Tokens - Expiration #17

Closed
poxin13 opened this issue Aug 18, 2016 · 2 comments
Closed

Personal Access Tokens - Expiration #17

poxin13 opened this issue Aug 18, 2016 · 2 comments

Comments

@poxin13
Copy link

poxin13 commented Aug 18, 2016

These tokens should expire just the same as regular client token correct?

I've set this up in AuthServiceProvider for testing:

Passport::tokensExpireIn(Carbon::now()->addMinute());
Passport::refreshTokensExpireIn(Carbon::now()->addMinute());

Yet i'm still authenticated well after that token should have been expired. Carbon is setup correctly, as I can output Carbon::now() directly as 2016-08-18 16:32:07.

I just noticed in the database the expires_at column is being written as: 2116-08-18 16:09:38. Very strange, all personal tokens seem to be adding 100 years.

@elynnaie
Copy link

The current docs say

Personal access tokens are always long-lived. Their lifetime is not modified when using the tokensExpireIn or refreshTokensExpireIn methods.

@overtrue
Copy link

overtrue commented Oct 31, 2018

// app/Providers/AppServiceProvider.php
//...
use Laravel\Passport\Bridge\PersonalAccessGrant;
use League\OAuth2\Server\AuthorizationServer;
//...

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     */
    public function boot()
    {
        $this->app->get(AuthorizationServer::class)
              ->enableGrantType(new PersonalAccessGrant(), new \DateInterval('P1W'));
    }
   
    //...
}
//...

About \DateInterval parameter:

https://secure.php.net/manual/en/dateinterval.construct.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants