PHPackages                             peterpetrus/passport-token - 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. peterpetrus/passport-token

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

peterpetrus/passport-token
==========================

Decoder for Laravel Passport (Bearer) Access Token

0.1(2y ago)20185.0k—9.9%51MITPHPPHP ^5.3.3 || ^7.0 || ^8.0

Since Dec 9Pushed 2y agoCompare

[ Source](https://github.com/peterpetrus/passport-token)[ Packagist](https://packagist.org/packages/peterpetrus/passport-token)[ RSS](/packages/peterpetrus-passport-token/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (13)Used By (1)

passport-token
==============

[](#passport-token)

Decoder for Laravel Passport (Bearer) Access Token.

Functionality
-------------

[](#functionality)

Decode Access-Token and return array with its IDs (token\_id, user\_id), Dates (date of expire, date of creation, start date) and validity and errors.

[ ![Donate with Lightning Network](https://camo.githubusercontent.com/11d2228a7a18299fa594edf92f16b2a13e0af4bdc97fab4508c31fd4cced79fa/68747470733a2f2f692e6962622e636f2f58374e7659546a2f646f6e6174652d776974682d6c6e2d6d696e692e706e67)](https://hydranode.org/btcpay/apps/2sYChS6rMmpzt7h9BhzCSZrbbXxB/pos "Donate with Lightning Network")Installation
------------

[](#installation)

Installation via composer:

```
composer require peterpetrus/passport-token
```

Example
-------

[](#example)

### Decode token as Object

[](#decode-token-as-object)

Object has same properties as returned array fields below.

```
use PeterPetrus\Auth\PassportToken;

$token = new PassportToken(
    'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjI2YTUyMTMxNDAzOGQ0NGY3OTVkMzYwZGQ0ZDlkNDBlYTQyNGU4N2ZlMjUyMmVhMTk5ZjU2ZWVmODg0ZTFhNWNmNjg2Nzk3NmQ2MDRmOWY5In0.eyJhdWQiOiIyIiwianRpIjoiMjZhNTIxMzE0MDM4ZDQ0Zjc5NWQzNjBkZDRkOWQ0MGVhNDI0ZTg3ZmUyNTIyZWExOTlmNTZlZWY4ODRlMWE1Y2Y2ODY3OTc2ZDYwNGY5ZjkiLCJpYXQiOjE1MTI3NDc1OTIsIm5iZiI6MTUxMjc0NzU5MiwiZXhwIjoxNTE4MTA0MzkyLCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.toksHokX_RZ7eRToL_owakMJ3gbi0nppD5yrhA9C5McVSnn3WraA4NwBcwQVlkv316BTUOaJ14unBNEg1UKGuK4EhoiTBMdT1cSkgH1HKZg2SXNBrCPi9YY4g4-4qpfxQqLeBM5JsVbouD6VeeBmDJUGVcoXDXimKEft4lgkIIqPCmWOV9HscKkRQ23lyVhXaQo4TMoCUZfM2ppyqdl2wTsrXp7woQMbqwVo9bnc4d6opj55XvMgal5MmY8YXDHpJO29UWkn2mTIL3kB6KP_WDHg5LJU0r1ua1lTn8Om97Z4eMFFUlipq7yODSgtML92kiZef7JAX3DecxJbzB9tcDk22NtSoBzlHy86ZJHU9rKhcIuKbpys6X2dAHAlkS7GUCWHqZcwN38LfjoyUEiP7QHkLNogSZQZE_I7FPKLYpxyOiR83K4IZGlOEeiEJZGCVqUWviyyIfWRA3gusk6p5cB4begxOne_l0vnNRH2WiB-WOKBytL1fKeXwaJj8AIFGj03Wvb0OYqp01ef05kiX9Y-PbHYYi_x5L8fcywXqo3ubKKiChqTCXirLH9ENcTwQT0C32Z2EgLlNnyF5iH9XQuW5UN36ke63ad0iIjlEhinoOOF8OK8IDKiHGIQ0qJwZxFG3EVDX3UFQpZUaAgYlNTTXhyT-fvf1dNR8msy-h0'
);

if ($token->valid) {
    // Check if token exists in DB (table 'oauth_access_tokens'), require \Illuminate\Support\Facades\DB class
    if ($token->existsValid()) {
        Auth::login(User::find($token->user_id));
        return redirect(...);
    }
}
```

### Decode token with static methods

[](#dec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63ad0iIjlEhinoOOF8OK8IDKiHGIQ0qJwZxFG3EVDX3UFQpZUaAgYlNTTXhyT-fvf1dNR8msy-h0'
);

if ($decoded_token['valid']) {
    // Check if token exists in DB (table 'oauth_access_tokens'), require \Illuminate\Support\Facades\DB class
    $token_exists = PassportToken::existsValidToken(
        $decoded_token['token_id'],
        $decoded_token['user_id']
    );

    if ($token_exists) {
        Auth::login(User::find($decoded_token['user_id']));
        return redirect(...);
    }
}
```

### Returned array $decoded\_token

[](#returned-array-decoded_token)

```
[
    "token_id" => "26a521314038d44f795d360dd4d9d40ea424e87fe2522ea199f56eef884e1a5cf6867976d604f9f9",
    "user_id" => "1",
    "expecting" => false,
    "start_at_unix" => 1512747592,
    "start_at" => "2017-12-08T15:39:52+0000",
    "incorrect" => false,
    "created_at_unix" => 1512747592,
    "created_at" => "2017-12-08T15:39:52+0000",
    "expired" => false,
    "expires_at_unix" => 1518104392,
    "expires_at" => "2018-02-08T15:39:52+0000",
    "error" => false,
    "errors" => [],
    "valid" => true
]
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 60% 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.

###  Release Activity

Cadence

Every ~192 days

Recently: every ~423 days

Total

12

Last Release

966d ago

PHP version history (2 changes)0.0.1PHP ^5.3.3 || ^7.0

0.0.10PHP ^5.3.3 || ^7.0 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/86c4ceabbe0abc0468ea769fd64fb09339683003aff8db98c490a71df4da4b88?d=identicon)[peterpetrus](/maintainers/peterpetrus)

---

Top Contributors

[![peterpetrus](https://avatars.githubusercontent.com/u/32982513?v=4)](https://github.com/peterpetrus "peterpetrus (3 commits)")[![gmutinel](https://avatars.githubusercontent.com/u/1876243?v=4)](https://github.com/gmutinel "gmutinel (1 commits)")[![pimplesushant](https://avatars.githubusercontent.com/u/3313656?v=4)](https://github.com/pimplesushant "pimplesushant (1 commits)")

---

Tags

access-tokenauthenticationdecoderlaravellaravel-passport

### Embed Badge

![Health badge](/badges/peterpetrus-passport-token/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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