Routes
Withroutes 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.
- The previous url is taken from
url_previous, or from theRefererheader. - After the callback, the user is signed in with the
guardof the config, with the remember option. - The browser is redirected back to the previous url, or to
app_url.
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:
?errorMessage=....
Passing data through the redirect
List request parameters instore 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_inis 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
Theonetap driver verifies the credential of the Google Identity Services script. Point its login_uri to the callback:
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
guardof the config. - Stateless login: pass the API token of the user with
store:
Disabling registration
With'register' => false, only existing users can sign in. A list of drivers allows registration only through them:
config/admin_socialite.php