CodeBriefly
Tech Magazine

Laravel Socialite GitHub Login (Part 3)

0 1,465

Get real time updates directly on you device, subscribe now.

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.

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”.

Laravel Socialite Github Login

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.

Laravel Socialite GitHub Login

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.

Laravel Socialite GitHub Login

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.

Laravel Socialite Github Login

After authorizing the app, you are redirecting back to your Laravel application.

Laravel Socialite Github Login

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

Get real time updates directly on you device, subscribe now.

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. AcceptRead More