PHPackages                             elytica/elytica-socialite - 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. elytica/elytica-socialite

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

elytica/elytica-socialite
=========================

Socialite provider for Laravel.

v1.2(2mo ago)232MITPHPPHP ^8.2CI passing

Since May 30Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/elytica/elytica-socialite)[ Packagist](https://packagist.org/packages/elytica/elytica-socialite)[ RSS](/packages/elytica-elytica-socialite/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (7)Versions (4)Used By (0)

Elytica Socialite Driver
========================

[](#elytica-socialite-driver)

Laravel Socialite driver for Elytica authentication.

- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [User model](#user-model)
- [Usage](#usage)
- [Scopes](#scopes)
- [Refreshing tokens](#refreshing-tokens)
- [Custom base URL](#custom-base-url)
- [Testing](#testing)

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11, 12, or 13
- `laravel/socialite` ^5.14

The package is auto-discovered — no manual provider registration needed.

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

[](#installation)

```
composer require elytica/elytica-socialite
```

Publish the config and migrations:

```
php artisan vendor:publish --provider="Elytica\Socialite\ElyticaServiceProvider" --tag=config
php artisan vendor:publish --provider="Elytica\Socialite\ElyticaServiceProvider" --tag=migrations
php artisan migrate
```

The migration adds the following nullable columns to your `users` table and makes `password` nullable (users authenticated via Elytica won't have a local password):

ColumnType`elytica_service_id`unsigned bigint`elytica_service_token`text`elytica_service_refresh_token`text`elytica_service_token_expires_at`timestampConfiguration
-------------

[](#configuration)

Add the following to your `.env` file:

```
ELYTICA_SERVICE_CLIENT_ID=your-client-id
ELYTICA_SERVICE_CLIENT_SECRET=your-client-secret
ELYTICA_SERVICE_REDIRECT_URI=https://your-app.com/auth/callback
ELYTICA_SERVICE_BASE_URL=https://service.elytica.com  # optional, defaults to service.elytica.com
```

The package merges its config into Laravel's `config/services.php` under the `elytica_service` key, so you can also override values there:

```
// config/services.php
'elytica_service' => [
    'client_id'     => env('ELYTICA_SERVICE_CLIENT_ID'),
    'client_secret' => env('ELYTICA_SERVICE_CLIENT_SECRET'),
    'redirect'      => env('ELYTICA_SERVICE_REDIRECT_URI'),
    'base_url'      => env('ELYTICA_SERVICE_BASE_URL'),
],
```

User model
----------

[](#user-model)

Add the Elytica columns to your `User` model so they can be mass-assigned and cast properly:

```
class User extends Authenticatable
{
    protected $fillable = [
        'name',
        'email',
        'password',
        'elytica_service_id',
        'elytica_service_token',
        'elytica_service_refresh_token',
        'elytica_service_token_expires_at',
    ];

    protected $hidden = [
        'password',
        'remember_token',
        'elytica_service_token',
        'elytica_service_refresh_token',
    ];

    protected function casts(): array
    {
        return [
            'email_verified_at'                => 'datetime',
            'password'                         => 'hashed',
            'elytica_service_token_expires_at' => 'datetime',
        ];
    }
}
```

Usage
-----

[](#usage)

```
