To install the Immutable X Socialite provider, run:
composer require socialiteproviders/immutablexPlease see the Base Installation Guide, then follow the provider specific instructions below.
'immutablex' => [
'client_id' => env('IMX_CLIENT_ID'),
'client_secret' => env('IMX_CLIENT_SECRET'),
'redirect' => env('IMX_REDIRECT_URI'),
],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('immutable', \SocialiteProviders\ImmutableX\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
\SocialiteProviders\Immutable\ImmutableXExtendSocialite::class.'@handle',
],
];Redirecting the User
To initiate the Immutable X login flow, use:
return Socialite::driver('immutablex')->redirect();Handling the Callback
After the user logs in, Immutable X will redirect them back to your application. Retrieve their information using:
$user = Socialite::driver('immutablex')->user();
$user->getId(); // Immutable X unique user ID
$user->getEmail(); // User's email address
$user->token; // OAuth access tokensub(string) Unique identifier for the user's account. e.g.248289761001email(string) User's email address.token(string) OAuth access token.
This package is open-source and released under the MIT License. See the LICENSE file for details.
For questions and support, open an issue in the GitHub repository.