Laravel Socialite GitHub Login (Part 3)
In this article, we will discuss “Laravel Socialite GitHub Login”. In this Laravel Socialite series, we already discussed Twitter and LinkedIn social login in our previous articles.
Table of Contents
Laravel Socialite GitHub Login
Prerequisites
You need to read out our previous posts on Laravel Socialite series.
Create GitHub Application
Time to create a GitHub application so visits “GitHub New Application Page”.
You need to fill the required form and register the GitHub application. After successful submission, you have been redirected to the application dashboard. Here you get the Client Id and Client Secret, which we required to complete our integration.
GitHub App Key and Secret
You need to update app key and app secret in the configuration file located at “config/services.php”.
return [ 'github' => [ 'client_id' => 'XXX-XXXX', 'client_secret' => 'XXX-XXX-XXXX', 'redirect' => 'http://localhost:8000/callback/github' ], ];
Add GitHub Login button in Login View
Add the following code snippet to your login form located at “resources/view/auth/login.blade.php”.
... <div class="form-group row mb-0"> <div class="col-md-12 text-center"> <p>----- Login via Social Profiles -----</p> <a href="{{url('/redirect/twitter')}}" class="btn btn-primary">Twitter</a> <a href="{{url('/redirect/linkedin')}}" class="btn btn-primary">Linkedin</a> <a href="{{url('/redirect/github')}}" class="btn btn-success">Github</a> </div> </div> ...
Finally, Login with GitHub
After updating everything, Let’s login with GitHub.
Now, you need to click on the GitHub login button. Here you have to sign in with your GitHub profile and authorize the app to use your profile and email address.
After authorizing the app, you are redirecting back to your Laravel application.
Conclusion
In this article, we are discussing the “Laravel Socialite GitHub Login”. I’m trying to explain to you each of the required details. You are requested to read our previous post on Twitter and LinkedIn for better understanding because I’m not adding the common code example’s again in this post. We will discuss other platforms such as Facebook, Google, GitLab, and Bitbucket in our future posts. Please feel free to add your comment if any query or submit your feedback 🙂
If you like our content, please consider buying us a coffee.
Thank you for your support!
Buy Me a Coffee