PHPackages                             luchavez/passport-pgt-client - 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. luchavez/passport-pgt-client

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

luchavez/passport-pgt-client
============================

Laravel Passport Password Grant Tokens Client for Laravel 8|9|10

2.0.2(2y ago)02591MITPHPPHP ^8.0

Since Aug 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/luchavez-technologies/passport-pgt-client)[ Packagist](https://packagist.org/packages/luchavez/passport-pgt-client)[ Docs](https://github.com/luchavez-technologies/passport-pgt-client)[ RSS](/packages/luchavez-passport-pgt-client/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (5)Versions (6)Used By (1)

Passport Password Grant Tokens (PGC) Client for Laravel 8|9|10
==============================================================

[](#passport-password-grant-tokens-pgc-client-for-laravel-8910)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0deeed9496dca463c1f96a10829cfa7bd710a55391fdd2aed0d852fbdaf19c36/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c7563686176657a2f70617373706f72742d7067742d636c69656e742e737667)](https://packagist.org/packages/luchavez/passport-pgt-client)[![Total Downloads](https://camo.githubusercontent.com/fe85560c45b4ecb490b03990950aa541cc6ba601fd3714d5dea58913e2428f67/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c7563686176657a2f70617373706f72742d7067742d636c69656e742e737667)](https://packagist.org/packages/luchavez/passport-pgt-client)[![GitHub Repo stars](https://camo.githubusercontent.com/94d1bf7765ecc403687b6fb1991ad58585c4ad6d652a7e3960c2b26e8b11e94f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6c7563686176657a2d746563686e6f6c6f676965732f70617373706f72742d7067742d636c69656e74)](https://github.com/luchavez-technologies/passport-pgt-client)[![Discord](https://camo.githubusercontent.com/bd46299a29c3cae288e34846117d44d0cb853da2dad0c376fd8bca3fc269f3b6/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f313134333734343631393935363430343239353f636f6c6f723d386339656666266c6162656c3d446973636f7264266c6f676f3d646973636f7264)](https://discord.gg/MBxxAkQAxx)[![Twitter Follow](https://camo.githubusercontent.com/516380eada3f11aaafd758d9d0b03958251eca9097ba558c3ae9ff53ee59820a/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f6c7563686176657a74656368)](https://twitter.com/luchaveztech)

**Laravel Passport** is an authentication package for Laravel. It is used by a lot of Laravel apps to authenticate users before accessing any resources. Basically, it generates an `access token` which you can then use on every request to provide identification to the `OAuth Server`.

One of Laravel Passport's mostly used authentication methods is the [`Password Grant Tokens`](https://laravel.com/docs/8.x/passport#password-grant-tokens) grant type. It is a stateless way to get `access tokens` and `refresh tokens` from the `OAuth Server`.

Take a look at [contributing.md](contributing.md) if you want to contribute to this project.

[![Passport PGT Client-Server](./images/passport-pgt.png)](./images/passport-pgt.png)

Installation
------------

[](#installation)

Via Composer

```
// Install the package
$ composer require luchavez/passport-pgt-client

// Publish the config
$ php artisan pgt:client:install
```

Setting Up
----------

[](#setting-up)

1. Add these variables to `.env` file if you want to override the default values.

Variable NameDefault ValueDescription`PASSPORT_URL``config('app.url')`URL of Authentication Server`PASSPORT_PASSWORD_GRANT_CLIENT_ID`nullPassword grant client's ID`PASSPORT_PASSWORD_GRANT_CLIENT_SECRET`nullPassword grant client's secretUsage
-----

[](#usage)

### Passport PGT Client

[](#passport-pgt-client)

The package provides a service called [**PassportPgtClient**](src/Services/PassportPgtClient.php) which you can use by calling its [helper functions](helpers/passport-pgt-client-helper.php):

1. `passportPgtClient()`
2. `passport_pgt_client()`

Here's the list of its available methods.

Method NameReturn TypeDescription`getPassportUrl``string`gets the URL of Authentication Server`getPasswordGrantClientId``string or int or null`gets the Password Grant Client's id`getPasswordGrantClientSecret``string or null`gets the Password Grant Client's secret`register``Luchavez\ApiSdkKit\Models\AuditLog or Illuminate\Http\Client\Response`sends POST request to Auth Server's `/oauth/token` to login`login``Luchavez\ApiSdkKit\Models\AuditLog or Illuminate\Http\Client\Response`sends POST request to Auth Server's `/oauth/token` to login`refreshToken``Luchavez\ApiSdkKit\Models\AuditLog or Illuminate\Http\Client\Response`sends POST request to Auth Server's `/oauth/token` to refresh tokens`logout``Luchavez\ApiSdkKit\Models\AuditLog or Illuminate\Http\Client\Response`sends POST request to Auth Server's `/api/oauth/logout` to logout`getSelf``Luchavez\ApiSdkKit\Models\AuditLog or Illuminate\Http\Client\Response`sends GET request to Auth Server's `/api/oauth/me` to get user info### Routes

[](#routes)

Here's the list of routes that this package provides.

MethodRouteDescriptionPOST`/api/register`This route sends POST request to Auth Server's `/api/oauth/register` to register.POST`/api/login`This route sends POST request to Auth Server's `/oauth/token` to login.POST`/api/refresh-token`This route sends POST request to Auth Server's `/oauth/token` to refresh tokens.POST`/api/logout`This route sends POST request to Auth Server's `/api/oauth/logout` to logout.GET`/api/me`This route sends GET request to Auth Server's `/api/oauth/me` to get user info.*Note*: If you wish to override the login, refresh token, logout, or get self logic, feel free to do so by updating the published `passport-pgt-client` config file.

### Examples

[](#examples)

- Logging in a user

[![Login Success](./images/login-success.png)](./images/login-success.png)

- Refreshing tokens

[![Refresh Token Success](./images/refresh-token-success.png)](./images/refresh-token-success.png)

- Getting user's information based on access token

[![Get Self Success](./images/me-success.png)](./images/me-success.png)

- Logging out a user

[![Logout Success](./images/logout-success.png)](./images/logout-success.png)

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [James Carlo Luchavez](https://github.com/luchavez-technologies)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~8 days

Total

4

Last Release

968d ago

Major Versions

1.0.0 → 2.0.02023-09-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/9751834583538187236ea6491879aa80263a43dd036aa4e4fd0a71f721a0bed4?d=identicon)[jamescarloluchavez](/maintainers/jamescarloluchavez)

---

Top Contributors

[![luchtech](https://avatars.githubusercontent.com/u/26067874?v=4)](https://github.com/luchtech "luchtech (9 commits)")

---

Tags

laraveloauth2PassportPgtClient

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/luchavez-passport-pgt-client/health.svg)

```
[![Health](https://phpackages.com/badges/luchavez-passport-pgt-client/health.svg)](https://phpackages.com/packages/luchavez-passport-pgt-client)
```

###  Alternatives

[kronthto/laravel-oauth2-login

Provides a middleware to protect resources requiring an OAuth2 login

2117.5k1](/packages/kronthto-laravel-oauth2-login)

PHPackages © 2026

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