Social Authentication with Socialite
The next step in todays project is to integrate Social Authentication. I don’t need any user details, rather not deal with lost passwords, forms and the likes so Social Authenticaton is the best bet for me, it’s fast and easy.
Using Laravels Socialite
I went over to the github page for socialite and copied its directions for installation, pretty simple. Of course I did have issues, copy/pasting their example didn’t yeild a working authentication system, sure I authed with the Social Network but not Laravel, so gg.
Migrate Laravels Users table
If you dont have the Users table already migrated go ahead and do it now.
php artisan migrate
composer require laravel/socialite
Add to config/app.php
Register the provider
'providers' => [ ... Laravel\Socialite\SocialiteServiceProvider::class, ],
'aliases' => [ ... 'Socialite' => Laravel\Socialite\Facades\Socialite::class, ],
Add to config/services.php
For each Social Network you want to auth with add its configuration, be sure to replace client_id and client_secret with your information:
'github' => [ 'client_id' => 'your-github-app-id', 'client_secret' => 'your-github-app-secret', 'redirect' => 'http://localhost:8000/auth/github/callback', ],
Replace the redirect with your url, unless you’re like me and just testing locally.
Replace the github parts with the name of the driver.
Originally published at www.laravelfeed.com.