PHPackages                             mhd-euro-flash/laravel-social-auth-support-laravel-9 - 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. mhd-euro-flash/laravel-social-auth-support-laravel-9

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

mhd-euro-flash/laravel-social-auth-support-laravel-9
====================================================

Easy social auth integration with a lot of available providers

1848PHP

Since Jan 29Pushed 3y agoCompare

[ Source](https://github.com/mhdEurFlash123/laravel-social-auth-support-laravel-9)[ Packagist](https://packagist.org/packages/mhd-euro-flash/laravel-social-auth-support-laravel-9)[ RSS](/packages/mhd-euro-flash-laravel-social-auth-support-laravel-9/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://stand-with-ukraine.pp.ua)

Social Authentication
=====================

[](#social-authentication)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0c92439ab1723b933f51176f218e4946be8627907f61650ee9cdb5c83aa21af1/68747470733a2f2f706f7365722e707567782e6f72672f6d61642d7765622f6c61726176656c2d736f6369616c2d617574682f762f737461626c652e7376673f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/mad-web/laravel-social-auth)[![Software License](https://camo.githubusercontent.com/37ca005da116947d902c47817b388dcd9b555c69e08fd36e95c513eb635702d4/68747470733a2f2f706f7365722e707567782e6f72672f6d61642d7765622f6c61726176656c2d736f6369616c2d617574682f6c6963656e73653f666f726d61743d666c61742d737175617265)](LICENSE.md)[![Build Status](https://github.com/mad-web/laravel-initializer/workflows/tests/badge.svg)](https://github.com/mad-web/laravel-social-auth/actions)[![Code Style](https://camo.githubusercontent.com/5039e5254edbf20e978b34caea7abf8e7ee82212aae51cb69630ad24f0c160b5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d61642d7765622f6c61726176656c2d736f6369616c2d617574682f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/mad-web/laravel-social-auth/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Quality Score](https://camo.githubusercontent.com/4baa64da83771316d45eea8442573b21e334928263eb336b43c0eae2100696cf/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d61642d7765622f6c61726176656c2d736f6369616c2d617574682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/mad-web/laravel-social-auth)[![Total Downloads](https://camo.githubusercontent.com/6a48c6b2ea0937005347452e214fd00599d4aa9d63bf7cab41206de8b7f7155b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61642d7765622f6c61726176656c2d736f6369616c2d617574682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mad-web/laravel-social-auth)

This package give ability to

- Sign In
- Sign Up
- Attach/Detach social network provider to an existing account

This package based on [laravel/socialite](https://laravel.com/docs/5.7/socialite) and provide an easy ability of usage a lot of additional providers from [Socialite Providers](https://socialiteproviders.netlify.com/).

Install
-------

[](#install)

Via Composer:

```
$ composer require mad-web/laravel-social-auth
```

and add the service provider in config/app.php file:

```
'providers' => [
    // ...
    MadWeb\SocialAuth\SocialAuthServiceProvider::class,
];
```

Next, publish the migration with:

```
$ php artisan vendor:publish --provider="MadWeb\SocialAuth\SocialAuthServiceProvider" --tag="migrations"
```

The package assumes that your users table name is called "users". If this is not the case you should manually edit the published migration to use your custom table name.

After the migration has been published you can create the `social_providers` table for storing supported providers and `user_has_social_provider` pivot table for attaching providers to users by running migrations:

```
$ php artisan migrate
```

You can publish the config file with:

```
$ php artisan vendor:publish --provider="MadWeb\SocialAuth\SocialAuthServiceProvider" --tag="config"
```

This is the contents of the published `config/social-auth.php` config file:

```
return [

    /*
    |--------------------------------------------------------------------------
    | Additional service providers
    |--------------------------------------------------------------------------
    |
    | The social providers listed here will enable support for additional social
    | providers which provided by https://socialiteproviders.github.io/ just
    | add new event listener from the installation guide
    |
    */
    'providers' => [
        //
    ],

    'models' => [
        /*
         * When using the "UserSocialite" trait from this package, we need to know which
         * Eloquent model should be used to retrieve your available social providers. Of course, it
         * is often just the "SocialProvider" model but you may use whatever you like.
         */
        'social' => \MadWeb\SocialAuth\Models\SocialProvider::class,

        /*
         * User model which you will use as "SocialAuthenticatable"
         */
        'user' => \App\User::class,
    ],

    'table_names' => [

       /*
       |--------------------------------------------------------------------------
       | Users Table
       |--------------------------------------------------------------------------
       |
       | The table for storing relation between users and social providers. Also there is
       | a place for saving "user social network id", "token", "expiresIn" if it exist
       |
       */
        'user_has_social_provider' => 'user_has_social_provider',

        /*
        |--------------------------------------------------------------------------
        | Social Providers Table
        |--------------------------------------------------------------------------
        |
        | The table that contains all social network providers which your application use.
        |
        */
        'social_providers' => 'social_providers'
    ],

    'foreign_keys' => [

        /*
         * The name of the foreign key to the users table.
         */
        'users' => 'user_id',

        /*
         * The name of the foreign key to the socials table
         */
        'socials' => 'social_id'
    ],

    /*
    |--------------------------------------------------------------------------
    | Authentication redirection
    |--------------------------------------------------------------------------
    |
    | Redirect path after success/error login via social network
    |
    */
    'redirect' => '/home'
];
```

Or you can publish and modify view templates with:

```
$ php artisan vendor:publish --provider="MadWeb\SocialAuth\SocialAuthServiceProvider" --tag="views"
```

Also you can publish and modify translation file:

```
$ php artisan vendor:publish --provider="MadWeb\SocialAuth\SocialAuthServiceProvider" --tag="lang"
```

##### Add credetials to your project

[](#add-credetials-to-your-project)

Add providers to `config/services.php`:

```
'facebook' => [
    'client_id' => env('FB_ID'),
    'client_secret' => env('FB_SECRET'),
    'redirect' => env('FB_REDIRECT'),
],

'google' => [
    'client_id' => env('GOOGLE_ID'),
    'client_secret' => env('GOOGLE_SECRET'),
    'redirect' => env('GOOGLE_REDIRECT'),
],

'github' => [
    'client_id' => env('GITHUB_ID'),
    'client_secret' => env('GITHUB_SECRET'),
    'redirect' => env('GITHUB_REDIRECT'),
]
```

Add credantials to `.env`:

```
FB_ID=
FB_SECRET=
FB_REDIRECT=https://app.domain/social/facebook/callback

GOOGLE_ID=
GOOGLE_SECRET=
GOOGLE_REDIRECT=https://app.domain/social/google/callback

GITHUB_ID=
GITHUB_SECRET=
GITHUB_REDIRECT=https://app.domain/social/github/callback
```

After that, create your social providers in the database.

Using console command:

```
php artisan social-auth:add google --label=Google+
```

By model, for example in seeder:

```
SocialProvider::create(['slug' => 'google', 'label' => 'Google+']);
```

Or add records directly.

You can add additional scopes and parameters to the social auth request:

```
SocialProvider::create([
    'label' => 'github',
    'slug' => 'Github',
    'scopes' => ['foo', 'bar'],
    'parameters' => ['foo' => 'bar']
]);
```

To override default scopes:

```
$SocialProvider->setScopes(['foo', 'bar'], true);
```

##### Include social buttons into your templates

[](#include-social-buttons-into-your-templates)

```
 @include('social-auth::attach') // for authenticated user to attach/detach another socials
 @include('social-auth::buttons') // for guests to login via
```

##### Prepare your user model

[](#prepare-your-user-model)

Implement `SocialAuthenticatable` interface and add `UserSocialite` trait to your User model:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use MadWeb\SocialAuth\Traits\UserSocialite;
use MadWeb\SocialAuth\Contracts\SocialAuthenticatable;

class User extends Model implements SocialAuthenticatable
{
    use UserSocialite;
   ...
}
```

Additional Providers
--------------------

[](#additional-providers)

To use any of additional providers from [socialiteproviders.netlify.com](https://socialiteproviders.netlify.com), at first install it:

```
composer require socialiteproviders/instagram
```

next, add an event listener from guide to the `social-auth` config file:

```
/*
|--------------------------------------------------------------------------
| Additional service providers
|--------------------------------------------------------------------------
|
| The social providers listed here will enable support for additional social
| providers which provided by https://socialiteproviders.netlify.com just
| add new event listener from the installation guide
|
*/
'providers' => [
    SocialiteProviders\Instagram\InstagramExtendSocialite::class,
],
...
```

Customization
-------------

[](#customization)

### Routes

[](#routes)

If you need do some custom with social flow, you should define yourself controllers and put your custom url into routes file.

For example:

```
Route::get('social/{social}', 'Auth\SocialAuthController@getAccount');
Route::get('social/{social}/callback', 'Auth\SocialAuthController@callback');
Route::get('social/{social}/detach', 'Auth\SocialAuthController@detachAccount');
```

In case if you no need any special functionality ypu can use our default controllers.

### Custom User Model

[](#custom-user-model)

User model we takes from the `social-auth.models.user`.

### User Properties Mapping

[](#user-properties-mapping)

`SocialAuthenticatable` interface contains method `mapSocialData` for mapping social fields for user model. If you need customize a data mapping, you can override this method for your preferences project in the `User` model.

Default mapping method:

```
public function mapSocialData(User $socialUser)
{
    $raw = $socialUser->getRaw();
    $name = $socialUser->getName() ?? $socialUser->getNickname();
    $name = $name ?? $socialUser->getEmail();

    $result = [
        $this->getEmailField() => $socialUser->getEmail(),
        'name' => $name,
        'verified' => $raw['verified'] ?? true,
        'avatar' => $socialUser->getAvatar(),
    ];

    return $result;
}
```

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

[](#change-log)

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

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Mad Web](https://github.com/mad-web)
- [All Contributors](link-contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/7df8a670b6de75318b29d8dc79b40aa8bfaa093e92ca3091112fc1e2c3cda899?d=identicon)[mhdEurFlash123](/maintainers/mhdEurFlash123)

---

Top Contributors

[![mhdEurFlash123](https://avatars.githubusercontent.com/u/117361811?v=4)](https://github.com/mhdEurFlash123 "mhdEurFlash123 (11 commits)")[![SerhiiStarovoitov](https://avatars.githubusercontent.com/u/6624912?v=4)](https://github.com/SerhiiStarovoitov "SerhiiStarovoitov (1 commits)")[![slavarazum](https://avatars.githubusercontent.com/u/5820718?v=4)](https://github.com/slavarazum "slavarazum (1 commits)")[![thewebartisan7](https://avatars.githubusercontent.com/u/57477934?v=4)](https://github.com/thewebartisan7 "thewebartisan7 (1 commits)")

### Embed Badge

![Health badge](/badges/mhd-euro-flash-laravel-social-auth-support-laravel-9/health.svg)

```
[![Health](https://phpackages.com/badges/mhd-euro-flash-laravel-social-auth-support-laravel-9/health.svg)](https://phpackages.com/packages/mhd-euro-flash-laravel-social-auth-support-laravel-9)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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