What is Laravel Socialite?

Author - Webner
28.09.2020
|
0 Comments
||

Most of the sites require User login and registration with Social sites like Facebook, Google+, etc. Laravel provides a simple way to authenticate with OAuth provider Socialite. Laravel currently supports Facebook, Google, Twitter, GitHub, Bitbucket, etc.

Installing and configuring

composer require laravel/socialite

Laravel 1

After installation, the Socialite package needs to add its credentials to service.php in the config folder.
'github' => [
'client_id' => env('Facebook_CLIENT_ID'),
'client_secret' => env('Facebook_CLIENT_SECRET'),
'redirect' => 'http://your-callback-url',
],

Also need to add socialite service and provide facade should register as like other packages use in Laravel, config/app.php

laravel 2

Routing for login with social

Laravel 3

Here using two routes:

  1. Redirection the user to OAuth Provider
  2. Receiving the call from the provider after authentication.

Example for github Login with Socialite.

pic3

Using the different type of parameters which redirect the requests like with, use the Scope before redirecting the user, add some information, set the Scope to override all the existing scopes

return

Fetch the User detail

pic4

Retrieve the user information with the given token and store it to the database through the Laravel application.

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *