PHPackages                             codewiser/socialiteprovider - 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. codewiser/socialiteprovider

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

codewiser/socialiteprovider
===========================

Zenit OAuth2 Provider for Laravel Socialite

v1.1.5(6mo ago)0859↓50%1MITPHPPHP ^7.4 || ^8.0

Since Aug 10Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/C0deWiser/socialiteprovider)[ Packagist](https://packagist.org/packages/codewiser/socialiteprovider)[ RSS](/packages/codewiser-socialiteprovider/feed)WikiDiscussions main Synced 1mo ago

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

Zenit
=====

[](#zenit)

```
composer require codewiser/socialiteprovider
```

Installation &amp; Basic Usage
------------------------------

[](#installation--basic-usage)

Please see the [Base Installation Guide](https://socialiteproviders.com/usage/), then follow the provider specific instructions below.

### Add configuration to `config/services.php`

[](#add-configuration-to-configservicesphp)

```
'zenit' => [
  'base_uri' => env('ZENIT_SERVER'),
  'client_id' => env('ZENIT_CLIENT_ID'),
  'client_secret' => env('ZENIT_CLIENT_SECRET'),
  'redirect' => env('ZENIT_REDIRECT_URI'),
  // optional attributes (with default values):
  'auth_endpoint' => 'auth',
  'token_endpoint' => 'oauth/token',
  'user_endpoint' => 'api/user',
  'token_introspect_endpoint' => 'token_info',
  'client_manage_endpoint' => 'oauth/client',
],
```

### Add provider event listener

[](#add-provider-event-listener)

Configure the package's listener to listen for `SocialiteWasCalled` events.

Add the event to your `listen[]` array in `app/Providers/EventServiceProvider`. See the [Base Installation Guide](https://socialiteproviders.com/usage/) for detailed instructions.

```
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        \SocialiteProviders\Zenit\ZenitExtendSocialite::class,
    ],
];
```

### Usage

[](#usage)

You should now be able to use the provider like you would regularly use Socialite (assuming you have the facade installed):

```
return Socialite::driver('zenit')->redirect();
```

### Returned User fields

[](#returned-user-fields)

- `id`
- `nickname`
- `name`
- `email`
- `avatar`

### Access Token

[](#access-token)

Access Token is now an object, not just a string.

```
$user = Socialite::driver('zenit')->user();

$token = $user->token;

// \League\OAuth2\Client\Token\AccessToken
```

### Error Response

[](#error-response)

Package provides response error handling compliant to rfc6749.

```
try {

    $user = Socialite::driver('zenit')->user();

} catch (OAuth2Exception $e) {

    return match ($e->getError()) {

        // Show response to the user
        'access_denied',
        'server_error',
        'temporarily_unavailable' =>

            redirect()
                ->to(route('login'))
                ->with('error', $e->getMessage()),

        // Silently
        'interaction_required' => redirect()->to('/'),

        // Unrecoverable
        default => throw $e,
    };
}
```

Token Introspection
-------------------

[](#token-introspection)

Package provides token introspection compliant to rfc7662.

```
use \Illuminate\Http\Request;
use \SocialiteProviders\Zenit\rfc7662\IntrospectedTokenInterface;

public function api(Request $request) {

    /** @var IntrospectedTokenInterface $token */
    $token = Socialite::driver('zenit')
                ->introspectToken($request->bearerToken());

    if ($token->isActive()) {
        //
    }
}
```

Get user using existing token
-----------------------------

[](#get-user-using-existing-token)

```
$user = Socialite::driver('zenit')
            ->userFromToken($request->bearerToken());
```

Refreshing Token
----------------

[](#refreshing-token)

```
$token = Socialite::driver('zenit')
            ->refreshToken($refresh_token);
```

Client Token
------------

[](#client-token)

```
$token = Socialite::driver('zenit')
            ->grantClientCredentials('scope-1 scope-2');
```

Token by username and password
------------------------------

[](#token-by-username-and-password)

```
$token = Socialite::driver('zenit')
            ->grantPassword($username, $password, 'scope-1 scope-2');
```

Token by custom grant
---------------------

[](#token-by-custom-grant)

```
$token = Socialite::driver('zenit')
            ->grant('custom_grant', [/* any request params */]);
```

Manage client
-------------

[](#manage-client)

Package provides remote client management compliant to rfc7592. It allows to read OAuth client properties...

```
use SocialiteProviders\Zenit\ClientConfiguration;

$config = new ClientConfiguration(
    Socialite::driver('zenit')->getClientConfiguration()
);
```

...and update it programmatically:

```
use SocialiteProviders\Zenit\ClientConfiguration;
use SocialiteProviders\Zenit\ClientScope;

$config = new ClientConfiguration();

$config->name = 'name';
$config->namespace = 'namespace';
$config->redirect_uri = 'https://example.com';

$scope = new ClientScope();

$scope->name = 'name';
$scope->description = 'description';
$scope->aud = ['personal'];
$scope->realm = 'public';

$config->scopes->add($scope)

// etc

Socialite::driver('zenit')->updateClientConfiguration($config->toUpdateArray());
```

Token authorization
-------------------

[](#token-authorization)

Register auth driver, that would authorize incoming requests with bearer tokens, issued by oauth server.

Provide a cache instance to store introspected tokens.

You may pass a callback to make additional checks with an authenticated user.

```
use SocialiteProviders\Zenit\Auth\TokenAuthorization;
use Laravel\Socialite\Facades\Socialite;
use Illuminate\Support\Facades\Auth;
use Illuminate\Contracts\Auth\Authenticatable;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

Auth::viaRequest('access_token', new TokenAuthorization(
    'zenit',
    Auth::createUserProvider(config('auth.guards.api.provider')),
    cache()->driver(),
    function(Authenticatable $user) {
        if ($user->trashed()) {
            throw new AccessDeniedHttpException('Account is disabled');
        }
    }
));
```

Next, register driver for the guard:

```
'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],
    'api' => [
        'driver' => 'access_token',
        'provider' => 'users',
    ]
]
```

Usually, *access\_token* associated with a user, but `client_credentials` *access\_token* is not. Such *access\_token* associated with oauth client only.

So, the `Authenticatable` may be as `App\User`, as `SocialiteProviders\Zenit\Auth\Client` class.

We expect that `User` implements `Laravel\Sanctum\Contracts\HasApiTokens`, as `Client` implements it too. If so, the `Authenticatable` will be injected with incoming token (aka current access token).

Current access token implements `Laravel\Sanctum\Contracts\HasAbilities`interface, so you may inspect its scopes and abilities.

```
use Illuminate\Http\Request;
use Laravel\Sanctum\Contracts\HasApiTokens;

public function index(Request $request) {
    // Check scope
    $request->user()->tokenCan('my-scope');
}
```

As current access token looks and behave like `Sanctum` token, we may protect routes with `Laravel\Sanctum\Http\Middleware\CheckAbilities` or `Laravel\Sanctum\Http\Middleware\CheckForAnyAbility` middlewares, as described in [official documentation](https://laravel.com/docs/12.x/sanctum#token-ability-middleware).

```
Route::get('/orders', function () {
    // Token has both "check-status" and "place-orders" abilities...
})->middleware(['auth:api', 'abilities:check-status,place-orders']);
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance66

Regular maintenance activity

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

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 ~35 days

Recently: every ~68 days

Total

24

Last Release

203d ago

PHP version history (2 changes)v1.0.0PHP ^7.2 || ^8.0

v1.0.11PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce23eaf7ae48d79d2b07efc83ff7cecb2664f428bd531b167b90169423f1453d?d=identicon)[Cellard](/maintainers/Cellard)

---

Top Contributors

[![Cellard](https://avatars.githubusercontent.com/u/1220316?v=4)](https://github.com/Cellard "Cellard (30 commits)")

---

Tags

fc-zenitlaraveloauth2socialite

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codewiser-socialiteprovider/health.svg)

```
[![Health](https://phpackages.com/badges/codewiser-socialiteprovider/health.svg)](https://phpackages.com/packages/codewiser-socialiteprovider)
```

###  Alternatives

[tuandm/laravue

A beautiful dashboard for Laravel built by VueJS

2.2k16.6k](/packages/tuandm-laravue)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6712.1k2](/packages/hasinhayder-tyro)[thathoff/kirby-oauth

Kirby OAuth 2 Plugin

3823.9k](/packages/thathoff-kirby-oauth)

PHPackages © 2026

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