crudadmin/socialite connects Laravel Socialite with CrudAdmin. After a social login it finds the user by e-mail or provider id, or registers a new one. Then it fills in the e-mail, name, avatar and provider columns, and either signs the user in or returns an API token.
Requirements
Version 2.x supports CrudAdmin 6, version 1.x supports CrudAdmin 3 to 5. It installslaravel/socialite, socialiteproviders/manager and google/apiclient.
Installation
config/admin_socialite.php. The package has no migrations. The columns come from the fields of your user model.
Configuration
config/admin_socialite.php
Providers
Install and register the SocialiteProviders package of the providers which are not in Laravel Socialite:
app/Providers/EventServiceProvider.php
Credentials
The package adds theservices config of Google, Facebook, Apple, PayPal and Instagram. The redirect url is {SOCIALITE_APP_URL}/socialite/{driver}/callback, SOCIALITE_APP_URL defaults to APP_URL.
- A provider defined in your
config/services.phpreplaces the whole block of the package. - With
APPLE_PRIVATE_KEY, the package generates the client secret of Apple for every callback, soAPPLE_CLIENT_SECRETcan stay empty. PAYPAL_MODE=sandboxswitches thepaypaldriver to the sandbox.
User model
The package writes into these fields when they exist in the user model:app/Models/User.php
- When
usernameis required and the provider returns no name, the package callsgenerateUsername()of the model when it exists. - Stateless flows create a token with
createToken(). UseHasApiTokensof Sanctum in the model.