Setting Up Laravel Socialite Provider

Laravel SocialiteProvider is a great extension to the Laravel Socialite package that provides adding SSO capability to your app out of the box.

If you are looking to integrate with a OAuth provider that you could not find in Socialite, it would be a good idea to look for it in the SocialiteProvider documentation. If it is listed then integrating it in your app would be as fun as any of the standard Socialite channels (currently Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, and Bitbucket) is.

Two things that you would want to remember are:

  1. You need to have Socialite in place. So make sure you install Socialite before installing SocialiteProvider.
  2. You can keep using the existing functionality from Socialite. Use SocialiteProvider for just the new integration not being provided by Socialite.

The documentation by SocialiteProvide is quite straightforward:

  1. Install the package

    composer require socialiteproviders/trello
  2. Update config/app.php

    'providers' => [
    \SocialiteProviders\Manager\ServiceProvider::class, // add
  3. Update app\Providers\EventServiceProvider.php

    protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [

and you are done with the installation. Now just implementation remains.

Set up the:

  1. app related secrets in your .env

  2. configuration in your config/services.php

    'trello' => [    
    'client_id' => env('TRELLO_CLIENT_ID'),  
    'client_secret' => env('TRELLO_CLIENT_SECRET'),  
    'redirect' => env('TRELLO_REDIRECT_URI') 
  3. front-end triggers (buttons etc.) and your routes in web.php

    Route::get('/login',  function  ()  {
    	return  Socialite::driver('trello')
    	->setScopes(['read',  'activity:read_all'])
  4. logic to handle/save the response

    $user  =  Socialite::driver('trello')->user();
    $name  =  $user->accessTokenResponseBody['name'];