Convenient Webex OAuth for Laravel Projects with Socialite

November 17, 2021
Ashesh Singh
Ashesh SinghMember, Webex Solutions Developer Team
Convenient Webex OAuth for Laravel Projects with Socialite

Laravel is the most popular backend web framework with over 67k Stars on GitHub that boasts an expressive, elegant syntax and a vibrant ecosystem of projects. One such project is Laravel Socialite, which simplifies authenticating with OAuth providers, enabling a third-party application to access an HTTP service. Although out-of-the-box such support is limited to only a handful of platforms, community-driven Socialite Providers packages can easily extend compatibility to others, including Webex.

That is an exciting development since Laravel based projects can use this single, consistent interface to authenticate with Webex in addition to already supported platforms like Microsoft Azure, Auth0, Bitbucket, GitHub, Strava, Telegram, and many more! You can find the complete list of supported platforms on the project's website The project currently supports more than 50 platforms.


If you are already familiar with Socialite, follow the steps below to use the new Socialite Providers Webex package.

Add the package

Add the package as a project dependency using Composer:

composer require socialiteproviders/webex
Add a new service configuration

Edit the config/services.php file:

'webex' => [
  'client_id' => env('WEBEX_CLIENT_ID'),
  'client_secret' => env('WEBEX_CLIENT_SECRET'),
  'redirect' => env('WEBEX_REDIRECT_URI')
Add a new service provider
  • Remove Laravel\Socialite\SocialiteServiceProvider from your providers[] array in config\app.php if you have added it already.
  • Add \SocialiteProviders\Manager\ServiceProvider::class to your providers[] array in config\app.php.

For example:

'providers' => [
    // a whole bunch of providers
    // remove 'Laravel\Socialite\SocialiteServiceProvider',
    \SocialiteProviders\Manager\ServiceProvider::class, // add

Add a provider event listener

Configure the package's listener to listen for SocialiteWasCalled events.

Add the event to your listen[] array in app/Providers/EventServiceProvider:

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers

See the Base Installation Guide for detailed instructions.


You should now be able to use the provider like you would regularly use Socialite (assuming you have the facade installed):

return Socialite::driver('webex')->redirect();
Returned User fields

The following user fields are returned:

  • id
  • nickname (may be null)
  • name (may be null)
  • first_name (may be null)
  • last_name (may be null)
  • email
  • avatar (may be null)


Wrapping Up

This article provided a brief overview of the new Socialite Providers Webex package. Laravel project owners are encouraged to use this package to simplify their workload when authenticating with Webex. To see other such community offerings or learn more about our developer platform, please visit Webex Developers.