Laravel 5.8 GitHub Login(using scaffold, no coding required)
When you search “Laravel GitHub Login” on Google, there are many articles telling you to install Socialite, then write controllers, views, and routes, it’s too tedious.
Following “DRY”, the same code should only be written once by one person, then share it as a package, others just install it, no coding required.
Nobody has done it, so I do it.
Do you know Laravel official command to make the login page? it’s
php artisan make:auth
I write a similar command to make the socialite login page:
composer require sinkcup/laravel-make-auth-socialite
php artisan make:auth-socialite
php artisan migrate
change config/services.php
'github' => [
'client_id' => env('GITHUB_CLIENT_ID'),
'client_secret' => env('GITHUB_CLIENT_SECRET'),
'redirect' => env('GITHUB_CALLBACK_URL'),
],
create an app on GitHub Developers OAuth Apps, then change .env
AUTH_SOCIAL_LOGIN_PROVIDERS=GitHub,Facebook
# GitHub allows localhost, it's very friendly to developers
GITHUB_CLIENT_ID=foo
GITHUB_CLIENT_SECRET=bar
GITHUB_CALLBACK_URL=http://localhost/login/github/callback
visiting the Login page in a browser, you can see everything is OK:
feel free to edit the pages:
resources/views/auth/login.blade.php
resources/views/user/profile_edit.blade.php
If you have any question, create an issue in the repo: github.com/sinkcup/laravel-make-auth-socialite