Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

moneal's avatar

How do you extend Socialite with a custom provider?

I would like to add a oauth2 provider to socialite but I don't get how to extend it. This is my first time trying to do something like this with a service provider and i'm totally lost.

0 likes
3 replies
fulup's avatar

I had the same objective and it's clear that socialite architecture is missing something to cleanly register new service providers without touching L5 core source code.

While I'm not 100% happy, I nevertheless find a workable solution.

In my application I wanted to add "Orange" as a new oAuth2 OpenID/Connect provider. Obviously Orange does not enter in Socialite model One/Two and not only I had to extend SocialiteManager + SocialiteServiceProvider. I also had to write a new Provider to support a full OpenID/Connect OAuth profile.

This being said if you extend Socialite Manager/provider and register your newly create provider in place of original Socialite one. It works.

  • use Laravel\Socialite\SocialiteManager;
  • class MySocialManager extends SocialiteManager {
  • protected function createOrangeDriver() {
  • $config = $this->app['config']['services.orange'];
  • // warning provider class must be a full namespace path
  • return $this->buildProvider(
  • // Orange require an OpenID/Connect provider
  • // for basic OAuth2 login use standard Socialite model One/Two
  • 'GeoToBe\Http\SocialAuth\OrangeProvider', $config
  • );
  • } -}

  • use Laravel\Socialite\SocialiteServiceProvider;

  • class SocialServiceProvider extends SocialiteServiceProvider {
  • public function register() {
  • $this->app->bindShared('Laravel\Socialite\Contracts\Factory', function($app)
  • {
  • return new MySocialManager($app);
  • });
  • }
  • }

In APP/config comment Socialite provider and add your own one.

3 likes
Surendaran_Cg's avatar

Can You Guys please help me. Im new to laravel and this topic too. I need to create a new customized provider but i cannot create it.

Please or to participate in this conversation.