# SapoId
composer require socialiteproviders/sapoid
# Installation & Basic Usage
Please see the Base Installation Guide (opens new window), then follow the provider specific instructions below.
# Add configuration to config/services.php
'sapoid' => [
'client_id' => env('SAPOID_CLIENT_ID'),
'client_secret' => env('SAPOID_CLIENT_SECRET'),
'redirect' => env('SAPOID_REDIRECT_URI'),
],
# 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.
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
$event->extendSocialite('sapoid', \SocialiteProviders\SapoId\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 (opens new window) for detailed instructions.
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
// ... other providers
\SocialiteProviders\SapoId\SapoIdExtendSocialite::class.'@handle',
],
];
# Configure App in SAPO ID
To configure your app in SAPO ID, you need to create an app in the SAPO ID Connect (opens new window) and get the client ID and client secret.
# Usage
You should now be able to use the provider like you would regularly use Socialite (assuming you have the facade installed):
return Socialite::driver('sapoid')->redirect();
To add more scopes you can use the below:
return Socialite::driver('sapoid')->scopes(['add','scopes','here'])->redirect();
Available scopes:
email
: provides access to user emailprofile
: provides access to user name and avatar
Access to these scopes must be configured per app in its config page: https://id.sapo.pt/connect/
# Returned User fields
The default scope only has the id
, other scopes are needed for name
, email
and avatar
id
: (string) The unique identifier for the user in SAPO ID.name
: (string|null) The full name of the user.email
: (string|null) The email address of the user.avatar
: (string|null) The URL of the user's avatar image.