savrx / savrx-passport-socialite
There is no license information available for the latest version (1.0.4) of this package.
1.0.4
2025-05-22 16:23 UTC
Requires
- php: ^8.0
- ext-json: *
- socialiteproviders/manager: ^4.4
README
composer require savrx-cloud/savrx-passport-socialite
Installation & Basic Usage
Please see the Base Installation Guide, then follow the provider specific instructions below.
Add configuration to config/services.php
'savrxpassport' => [ 'client_id' => env('SAVRXPASSPORT_CLIENT_ID'), 'client_secret' => env('SAVRXPASSPORT_CLIENT_SECRET'), 'redirect' => env('SAVRXPASSPORT_REDIRECT_URI'), 'host' => env('SAVRXPASSPORT_HOST'), ],
host
will generally always be set to https://auth.savrx.com/
but may be altered to accomodate separate dev environments
redirect
will be used to determine the redirect URI you wish to use
Add provider event listener
Laravel 11+
In Laravel 11, the default EventServiceProvider
provider was removed. Instead, add the listener using the listen
method on the Event
facade, in your AppServiceProvider
boot
method.
- Note: You do not need to add anything for the built-in socialite providers unless you override them with your own providers.
<?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Event; class AppServiceProvider extends ServiceProvider { /** * Register any application services. */ public function register(): void { // } /** * Bootstrap any application services. */ public function boot(): void { Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) { $event->extendSocialite('savrxpassport', \Savrx\SavrxPassportSocialite\Provider::class); }); } }
Laravel 10 or below
Configure the package's listener to listen for `SocialiteWasCalled` events.Add the event to your listen[]
array in app/Providers/EventServiceProvider
. See the Base Installation Guide for detailed instructions.
protected $listen = [ \SocialiteProviders\Manager\SocialiteWasCalled::class => [ // ... other providers Savrx\SavrxPassportSocialite\SavrxPassportExtendSocialite::class.'@handle', ], ];
Usage
You should now be able to use the provider like you would regularly use Socialite (assuming you have the facade installed):
// Initial redirect public function redirect() { // Remember to set scopes accordingly return Socialite::driver('savrxpassport') ->setScopes([ 'read-user', 'verify-admin-portal-access' ]) ->redirect(); } // public function callback() { $user = Socialite::driver('savrxpassport')->user(); if (!$user || !$user->token || !$user->refreshToken) { // handle auth failures return redirect('login.index'); } // authenticate return redirect('dashboard.index'); }
Returned User fields
id
nickname
name
email
avatar
- name and nickname are equivalent
- avatar is always
null