PHPackages                             quadram/laravel-passport - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. quadram/laravel-passport

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

quadram/laravel-passport
========================

This package install Laravel Passport library and gives you some useful resources to issue expiring and not expiring tokens for your users

0125PHPCI failing

Since Nov 24Pushed 5y ago2 watchersCompare

[ Source](https://github.com/quadramqs/quadram-laravel-passport)[ Packagist](https://packagist.org/packages/quadram/laravel-passport)[ RSS](/packages/quadram-laravel-passport/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

[![](https://camo.githubusercontent.com/df79d2eb9c852bb55abc356db57fd6a1e85d577ce23d94b75f6c58c5cd8f54d1/68747470733a2f2f7777772e7175616472616d2e6d6f62692f696d672f7175616472616d2d6465736172726f6c6c6f2d61706c69636163696f6e65732d6d6f76696c65732d616e64726f69642d6970686f6e652d322e706e67)](https://camo.githubusercontent.com/df79d2eb9c852bb55abc356db57fd6a1e85d577ce23d94b75f6c58c5cd8f54d1/68747470733a2f2f7777772e7175616472616d2e6d6f62692f696d672f7175616472616d2d6465736172726f6c6c6f2d61706c69636163696f6e65732d6d6f76696c65732d616e64726f69642d6970686f6e652d322e706e67)

[visit our website](https://www.quadram.mobi/)

Laravel Passport
----------------

[](#laravel-passport)

This library install Laravel Passport library and allow to issue access tokens for authenticated users. There's no need to redirect your users to the oauth routes, just use the current user instance to get a fresh access token or refresh it.

Install the project
-------------------

[](#install-the-project)

```
# require the library into your project
composer require quadram/laravel-passport

# install and configure library
php artisan quadram:laravel-passport-install

```

How to use
----------

[](#how-to-use)

Add the LaravelPassportTrait to your user model:

```
use Quadram\LaravelPassport\Traits\LaravelPassportTrait;

class User extends Model
{
    use LaravelPassportTrait, Authenticatable;
    ...

```

And use your user instance to issue a new access token for the user:

```
# access token
$this->createAccessToken();

# personal access token
$this->createPersonalToken();

```

These calls add a new authorization field to the user instance with this structure:

```
    accessToken = [
        'accessToken' => '....',
        'refreshToken' => '....',
        'expires' => 123456...
    ];

```

Testing
-------

[](#testing)

When you are testing your routes to issue tokens using phpunit the Trait will respond with a test token without calling the actual oauth route provided by Passport.

If you want to test any passport related feature you should pass an Authorization header to your route.

Also the trait will use the auth user for updating and deleting tokens so remember to use "Passport::actingAs" to avoid errors.

```
    $user = factory(User::class)->create();
    $user->createAccessToken();

    Passport::actingAs($user);

    $headers = [
        'Authorization' => 'Bearer ' . $user->authorization['accessToken']
    ];

    $this->withHeaders($headers)
        ->json('put', '/api/sessions', ['refreshToken' => $user->authorization['refreshToken']])
        ->assertStatus(200)
        ->assertsee('authorization')
        ->assertsee('accessToken')
        ->assertsee('refreshToken');

```

Environment values
------------------

[](#environment-values)

The default expiration times for each token can be configured using the .env file.

```
# Default expiration time for access tokens in minutes, default = 60 * 24 -> 1 day
# TOKEN_EXPIRES_IN_MINUTES

# Default expiration time for refresh tokens in minutes, default = 60 * 24 * 30 -> 30 days
# REFRESH_TOKEN_EXPIRES_IN_MINUTES

# Default expiration time for personal tokens in minutes, default = 60 * 24 * 30 * 12 * 100 -> 1 year
# PERSONAL_TOKEN_EXPIRES_IN_MINUTES

# Curl should verify SSL certificate when calling the server (default = false)
# PASSPORT_CURL_VERIFY_SSL

```

Todo Tasks

- Basic trait to issue tokens.
- Customize passport client to authorize the user.
- Add function to the trait to create a user.
- Make default routes for sessions management.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5cb064783a125198532d883070d029c0c7da8dd6d294c626954a0ee953f910fd?d=identicon)[victorlopezalonso](/maintainers/victorlopezalonso)

---

Top Contributors

[![victorlopezalonso](https://avatars.githubusercontent.com/u/19757355?v=4)](https://github.com/victorlopezalonso "victorlopezalonso (33 commits)")[![lmendez23](https://avatars.githubusercontent.com/u/43754541?v=4)](https://github.com/lmendez23 "lmendez23 (3 commits)")

### Embed Badge

![Health badge](/badges/quadram-laravel-passport/health.svg)

```
[![Health](https://phpackages.com/badges/quadram-laravel-passport/health.svg)](https://phpackages.com/packages/quadram-laravel-passport)
```

###  Alternatives

[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
