PHPackages                             hamedov/passport-grants - 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. hamedov/passport-grants

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

hamedov/passport-grants
=======================

Custom grants for laravel passport

4.1.3(4y ago)31341[1 PRs](https://github.com/hamedov93/passport-grants/pulls)MITPHPPHP ^7.3|^7.4|^8.0

Since Oct 29Pushed 2y ago3 watchersCompare

[ Source](https://github.com/hamedov93/passport-grants)[ Packagist](https://packagist.org/packages/hamedov/passport-grants)[ RSS](/packages/hamedov-passport-grants/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (10)Used By (0)

Passport grants
===============

[](#passport-grants)

Add custom grants to laravel passport.

Installation
============

[](#installation)

`composer require hamedov/passport-grants`

Supported passport versions
===========================

[](#supported-passport-versions)

Passport versionPassport grants version^7.0^1.0^8.0^2.0^9.0^3.0^10.0^4.0Usage
=====

[](#usage)

- Create a new grant:

We will be using facebook login as an example here

```
php artisan make:grant Facebook

```

This will create a new grant class in App\\Grants folder

- Specify unique identifier for your grant

```
protected $identifier = 'facebook';

```

- Specify The parameters you will be sending in access token request for user authentication instead of username and password

```
protected $authParams = [
    'jwt_token',
];

```

The access token request should look like this:

```
$response = $http->post(env('APP_URL') . '/oauth/token', [
    'form_params' => [
        'grant_type' => 'facebook',
        'client_id' => 'client-id',
        'client_secret' => 'client-secret',
        'jwt_token' => 'facebook access token',
        'scope' => '',
        'guard' => 'api',
    ],
]);

```

- Next add your authentication logic to `getUserEntityByAuthParams` method

You will receive an empty instance of the authenticated model as first parameter.

The second parameter is an associative array containing values of parameters specified in `authParams` property.

- The method implementation should be something like this:

```
protected function getUserEntityByAuthParams(Model $model, $authParams,
    $guard, $grantType, ClientEntityInterface $clientEntity)
{
    // Do your logic to authenticate the user.
    // Return false or void if authentication fails.
    // This will throw OAuthServerException.
    $facebookAccessToken = $authParams['jwt_token'];
    // Contact facebook server to make sure the token is valid and get the corresponding user profile.
    $profile = file_get_contents('https://graph.facebook.com/me?fields=name,email&access_token='.$facebookAccessToken);
    $profile = (array) json_decode($profile);
    if ( ! isset($profile['email'])) {
        // We cannot identify the user without his email address
        return;
    }

    // Retrieve user or any authenticatable model by email or create new one.
    $user = $model->firstOrCreate(['email' => $profile['email']], ['name' => $profile['name']]);

    return new User($user->getAuthIdentifier());
}

```

- You can use the previous example with any authenticatable entity.
- Add the new grant to grants section of config/auth.php

```
'grants' => [
    App\Grants\Facebook::class,
],

```

License
=======

[](#license)

Released under the Mit license, see [LICENSE](https://github.com/hamedov93/passport-multiauth/blob/master/LICENSE)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

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

###  Release Activity

Cadence

Every ~54 days

Recently: every ~98 days

Total

9

Last Release

1590d ago

Major Versions

1.0 → 2.02020-10-29

2.0 → 3.02020-10-29

3.0 → 4.02020-10-30

PHP version history (4 changes)1.0PHP ^7.1.3

2.0PHP ^7.2

4.0PHP ^7.3

4.1.0PHP ^7.3|^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/82c37e59c90c4c4b24cdb4e1dc98084ea2acd19e8cc1e8f7e928af64d39c05f2?d=identicon)[hamedov](/maintainers/hamedov)

---

Top Contributors

[![Saifallak](https://avatars.githubusercontent.com/u/6053156?v=4)](https://github.com/Saifallak "Saifallak (2 commits)")[![hamedov93](https://avatars.githubusercontent.com/u/13410895?v=4)](https://github.com/hamedov93 "hamedov93 (1 commits)")

---

Tags

laravelpassportcustomgrant

### Embed Badge

![Health badge](/badges/hamedov-passport-grants/health.svg)

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

###  Alternatives

[coderello/laravel-passport-social-grant

Social Grant for Laravel Passport

179607.4k3](/packages/coderello-laravel-passport-social-grant)[corbosman/laravel-passport-claims

Add claims to Laravel Passport JWT Tokens

88655.9k](/packages/corbosman-laravel-passport-claims)[jeremy379/laravel-openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

55342.3k2](/packages/jeremy379-laravel-openid-connect)[danjdewhurst/laravel-passport-facebook-login

Facebook Token Request Grant for Laravel Passport

2824.4k](/packages/danjdewhurst-laravel-passport-facebook-login)[mikemclin/passport-custom-request-grant

Custom Request Grant for Laravel Passport

343.6k](/packages/mikemclin-passport-custom-request-grant)[benbjurstrom/passport-custom-jwt-claims

Customize JWT claims in Laravel Passport access tokens

341.8k](/packages/benbjurstrom-passport-custom-jwt-claims)

PHPackages © 2026

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