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.