Laravel Socialite LinkedIn Login (Part 2)

0 487

In this article, we will discuss “Laravel Socialite LinkedIn Login”. We already discuss the Laravel Socialite in our previous post, where we describe the Twitter login process. So in this post, we will not be discussing the common process.

Laravel Socialite LinkedIn Login

Prerequisites

Please read out my previous post Laravel Socialite Twitter Login, here you get basic steps such as Setup Laravel Socialite, Controller, Modal, Route and etc.

Create LinkedIn App

You need to create LinkedIn App, So go to the LinkedIn Developer portal and log in with your LinkedIn profile.

Laravel Socialite LinkedIn Login

After login the LinkedIn developer account, time to create an app. So click on the create app button as shown in the above mention screenshot.

Laravel Socialite LinkedIn Login

You need to fill out the basic form to create an app as shown in the above screenshot.

After successful submission, you are redirected to the next page where you found your app client id and client secret. Also, here you have to add “OAuth 2.0 (Authorized Redirect URLs)” and “Default Accept/Cancel Redirect URLs”.

And don’t forget to add “r_emailaddress” application permission. Otherwise, user email is not received in your response.

Laravel Socialite LinkedIn Login

LinkedIn App Key and Secret

You need to update app key and app secret in the configuration file located at “config/services.php”.

'linkedin' => [
    'client_id' => 'XXXXXX',
    'client_secret' => 'XXXXXX',
    'redirect' => 'http://localhost:8000/callback/linkedin'
],

Add LinkedIn 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/linkedin')}}" class="btn btn-info">Linkedin</a>
    </div>
</div>

Finally, Login with LinkedIn

After updating everything, Let’s login with LinkedIn.
Laravel Socialite LinkedIn Login

Click on the LinkedIn login button. After that, you are redirected to the LinkedIn. Here you can sign in with your LinkedIn profile and authorize the app to use your profile and email address.

Laravel Socialite LinkedIn Login

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

Laravel Socialite LinkedIn Login

Conclusion

In this article, we are discussing the “Laravel Socialite LinkedIn Login”. I’m trying to explain to you each of the required details. You are requested to read our previous post “Laravel Socialite Twitter Login” for better understanding because I’m not adding the common code example’s again in this post. We will discuss other platforms such as GitHub, Facebook, Google, GitLab, and Bitbucket in our future posts. Please feel free to add your comment if any query or submit your feedback 😉

Leave A Reply

Your email address will not be published.