lopatin96/laravel-social-auth

Laravel social auth

1.0.14 2024-02-15 16:49 UTC

This package is auto-updated.

Last update: 2024-04-15 17:11:28 UTC


README

Views

Add these lines to resources/views/auth/login.blade.php:

<x-laravel-social-auth::socialite-login />

and these to resources/views/auth/register.blade.php:

<x-laravel-social-auth::socialite-register />

FortifyServiceProvider

Add these lines to app/Providers/FortifyServiceProvider.php as uses to manage redirections:

use Atin\LaravelSocialAuth\Http\Responses\LoginResponse;
use Laravel\Fortify\Contracts\LoginResponse as LoginResponseContract;
use Laravel\Fortify\Contracts\TwoFactorLoginResponse as TwoFactorLoginResponseContract;

then add singletons to boot method in app/Providers/FortifyServiceProvider.php:

public function boot(): void
{
    …
    $this->app->singleton(LoginResponseContract::class, LoginResponse::class);
    $this->app->singleton(TwoFactorLoginResponseContract::class, LoginResponse::class);
}

Trait

Add HasSocialAccount trait to User model:

use Atin\LaravelSocialAuth\Traits\HasSocialAccount;

class User extends Authenticatable
{
    use HasSocialAccount, …

Config

Public config:

php artisan vendor:publish --tag="laravel-social-auth-config"

and comment/uncomment providers in config/laravel-social-auth.php:

return [
    'providers' => [
        'google' => [
            'title' => 'Google',
        ],

        'facebook' => [
            'title' => 'Facebook'
        ],

//        'instagram' => [
//            'title' => 'Instagram'
//        ],
    ],
];

Configuration

Add these keys to config/services.php to manage google and facebook authentications:

'google' => [
    'api_key' => env('GOOGLE_API_KEY'),
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => env('GOOGLE_REDIRECT'),
],

'facebook' => [
    'client_id' => env('FACEBOOK_CLIENT_ID'),
    'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
    'redirect' => env('FACEBOOK_REDIRECT'),
],

Publishing

Migrations

php artisan vendor:publish --tag="laravel-social-auth-migrations"

Localization

php artisan vendor:publish --tag="laravel-social-auth-lang"

Views

php artisan vendor:publish --tag="laravel-social-auth-views"

Config

php artisan vendor:publish --tag="laravel-social-auth-config"