PHP code example of stechstudio / laravel-socialite-auth

1. Go to this page and download the library: Download stechstudio/laravel-socialite-auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stechstudio / laravel-socialite-auth example snippets


    'google' => [
        'client_id' => env('GOOGLE_CLIENT_ID'),
        'client_secret' => env('GOOGLE_CLIENT_SECRET'),
        'redirect' => route('socialite-auth.callback')
    ],
    

   public function getSocialiteIdentifierName()
   {
       return 'email';
   }
    
   public function getSocialiteIdentifier()
   {
       return $this->email;
   }
   

   SocialiteAuth::beforeLogin(function($user) {
       return str_contains($user->email, ['example.com']);
   });
   

'defaults' => [
    'guard' => 'socialite',
    ...
],

   protected $routeMiddleware = [
       ...
       'socialite' => \STS\SocialiteAuth\Authenticate::class,
       ...
   ];
   

   protected $middlewarePriority = [
       ...
       \STS\SocialiteAuth\Authenticate::class,
       \App\Http\Middleware\Authenticate::class,
       ...
   ];
   

Route::get(...)->middleware(['auth:socialite', 'socialite']);

Route::get(...)->middleware('auth');

   protected function routes()
   {
       Nova::routes();
           // ->withAuthenticationRoutes()
           // ->withPasswordResetRoutes()
           // ->register();
   }