saeedvir/socialite-slim

Laravel Socialite Slim provides a lightweight, expressive, fluent interface to OAuth authentication with Google, GitHub, and Telegram. It handles almost all of the boilerplate social authentication code you are dreading writing.

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/saeedvir/socialite-slim

v1.0.2 2025-11-13 04:44 UTC

This package is auto-updated.

Last update: 2025-11-13 04:46:08 UTC


README

Logo Laravel Socialite

Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Socialite Slim provides a lightweight, expressive, fluent interface to OAuth authentication with Google, GitHub, and Telegram. It handles almost all of the boilerplate social authentication code you are dreading writing.

Supported Providers

  • Google
  • GitHub
  • Telegram

OAuth Connected Users Feature

This package now includes a complete OAuth connected users system that allows you to track and manage OAuth connections for your users. See OAUTH-README.md for detailed documentation.

Installation

composer require saeedvir/socialite-slim

Publish Migrations

To use the OAuth connected users feature, publish the migrations:

php artisan vendor:publish --provider="Saeedvir\SocialiteSlim\SocialiteServiceProvider" --tag="socialite-migrations"

Then run the migrations:

php artisan migrate

Configuration

After installing the Socialite Slim library, register the Saeedvir\SocialiteSlim\SocialiteServiceProvider in your config/app.php configuration file:

'providers' => [
    // Other service providers...

    Saeedvir\SocialiteSlim\SocialiteServiceProvider::class,
],

Also, add the Socialite facade to the aliases array in your config/app.php configuration file:

'aliases' => [
    // Other aliases...

    'Socialite' => Saeedvir\SocialiteSlim\Facades\Socialite::class,
    'OAuth' => Saeedvir\SocialiteSlim\Facades\OAuth::class,
],

You will also need to add credentials for the OAuth services your application utilizes. These credentials should be placed in your config/services.php configuration file, and should use the key google, github, or telegram, depending on the providers your application needs:

'google' => [
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => 'http://your-callback-url',
],

'github' => [
    'client_id' => env('GITHUB_CLIENT_ID'),
    'client_secret' => env('GITHUB_CLIENT_SECRET'),
    'redirect' => 'http://your-callback-url',
],

'telegram' => [
    'client_id' => env('TELEGRAM_CLIENT_ID'),
    'client_secret' => env('TELEGRAM_CLIENT_SECRET'),
    'redirect' => 'http://your-callback-url',
],

Basic Usage

<?php

namespace App\Http\Controllers\Auth;

use Saeedvir\SocialiteSlim\Facades\Socialite;

class AuthController extends Controller
{
    /**
     * Redirect the user to the GitHub authentication page.
     *
     * @return \Illuminate\Http\Response
     */
    public function redirectToProvider()
    {
        return Socialite::driver('github')->redirect();
    }

    /**
     * Obtain the user information from GitHub.
     *
     * @return \Illuminate\Http\Response
     */
    public function handleProviderCallback()
    {
        $user = Socialite::driver('github')->user();

        // $user->token
    }
}

OAuth Connected Users Usage

To use the OAuth connected users feature, add the trait to your User model:

<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Saeedvir\SocialiteSlim\Traits\HasOAuthConnections;

class User extends Authenticatable
{
    use HasOAuthConnections;
    
    // ... rest of your model
}

Then you can use the OAuth facade to manage connections:

use Saeedvir\SocialiteSlim\Facades\OAuth;

// Find or create an OAuth connected user
$connectedUser = OAuth::findOrCreateOauthUser($provider, $providerId, $userData);

See OAUTH-README.md for complete documentation.

Documentation

For comprehensive documentation, please visit:

Contributing

Thank you for considering contributing to Socialite Slim! The contribution guide can be found in the GitHub repository.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

Laravel Socialite Slim is open-sourced software licensed under the MIT license.