Routes

With routes enabled, the package registers three routes in the web middleware group: Build the links with the route names, e.g. route('socialite.redirect', 'google'). Projects which only use the token login of crudadmin/helpers set 'routes' => false. Apple and Google One Tap send the callback as a POST request. Exclude socialite/* from CSRF verification when you use them.

Session login

The default for websites, 'stateless' => false.
  1. The previous url is taken from url_previous, or from the Referer header.
  2. After the callback, the user is signed in with the guard of the config, with the remember option.
  3. The browser is redirected back to the previous url, or to app_url.
Errors redirect back with the errorMessage key in the session errors.

Stateless login

For separate frontends, e.g. Nuxt, set 'stateless' => true. The flow is the same, but the user is not signed in to a session. The previous url receives the token in the query string:
Errors redirect with ?errorMessage=....

Passing data through the redirect

List request parameters in store to keep them until the callback. Read them with getStorage() in the hooks:

Token login

JSON requests return JSON instead of redirects. Mobile apps sign in with the native SDK of the provider and send its token:
POST /socialite/apple/token
  • Google and Facebook send an access token, Apple sends the identity token.
  • Apple sends the name of the user only on the first sign in. Pass it as username.
  • expires_in is stored in {prefix}_token_expires_at.

Token login with crudadmin/helpers

Apps using the helpers authentication call its route instead. It returns the same login response as the password login:
POST /api/auth/login/socialite/google

Google One Tap

The onetap driver verifies the credential of the Google Identity Services script. Point its login_uri to the callback:
The account is stored in the gp_* columns, the same as the google driver.

Linking accounts

A signed in user who goes through the login links the provider to his account. The provider id, e-mail and token are saved, the user is not changed otherwise.
  • Session login: the user is signed in with the guard of the config.
  • Stateless login: pass the API token of the user with store:
No new token is created in this case.

Disabling registration

With 'register' => false, only existing users can sign in. A list of drivers allows registration only through them:
config/admin_socialite.php