Social Authentication with Socialite
Learn how to implement social authentication in the Larafast API Boilerplate.
This document describes the social authentication logic implemented in the PHP Laravel application using the Socialite package. The logic is primarily handled by the SocialiteController
class.
Redirecting to the OAuth Provider
The redirect
method in the SocialiteController
class is used to redirect the user to the OAuth provider. The method accepts a driver
parameter which specifies the OAuth provider to use.
Handling Provider Callbacks
The callback
method in the SocialiteController
class is used to handle the callback from the OAuth provider. It retrieves the user details from the provider and creates or retrieves the corresponding user record in the application’s database.
Routes
The routes for social authentication are defined in the routes/auth.php
file. The routes use the SocialiteController
class, and the redirect
and callback
methods respectively. These routes are grouped under a middleware that ensures only guest users can access them.
This concludes the overview of the social authentication logic in the application.
To learn more on how to create Google, Twitter or Github OAuth applications, refer to the main doc Social Auth