Code2night
  • Home
  • Guest Posts
  • Tutorial
  • Languages
    • Angular
    • C
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
  • Register
  • Login
  1. Home
  2. Blogpost

Linkedin Sign In using LinkedinLogin Nuget package in Asp-Net MVC

Date- Jul 05,2022

8741

Free Download Pay & Download
LinkedinLogin LinkedinProfile

Hello guys and welcome to Code2Night! In this article, we'll take a look at how to integrate the Linkedin Sign In functionality using the LinkedinLogin Nuget package in an Asp-Net MVC application.  We'll cover everything you need to know to get up and running with this powerful authentication method, so let's get started!

Web developers are probably well aware of the requirement to integrate social logins into their applications. Users expect to be able to check in with their preferred platforms thanks to the growth of social media, rather than having to create yet another login and password. This enhances the user experience while also making it easier for developers to authenticate users.

One social login that has become increasingly popular is the Linkedin Login. With millions of professionals on the platform, it's a great option for applications targeting the business or career-oriented demographic.

 

Install-Package from Nuget Package Manager

So, we will be using a Nuget package that is used for linkedin login in two easy steps and is quite simple. So first of all you have to install the Nuget package that is shown in the image. 

Nuget Package


You can also install this Nuget package using the command in the package manager console

 Install-Package LinkedinLogin -Version 1.0.0

After you have successfully installed the LinkedinLogin page. You have to go to the controller and add code to your controller.

Now this method will return you the redirect URL which you have to add in your button href on view and on clicking that button it will redirect to the LinkedIn login screen. So we will be storing the information in ViewBag and passing that on to the view. So first do this on the controller side on the action which is fired when the page is loaded.

        public ActionResult Index()
        {
            ViewBag.uri = LinkedinLogin.LinkedinPackage.RedirectToLinkedinLoginUrl("ClientId", "redirectUri");
            ViewBag.url = LinkedinLogin.LinkedinPackage.RedirectToLinkedinLoginUrl("7710pzauu34u5oni12cxsabc", "http://localhost:8080/Home/RedirectLinkedIN");
            return View();
        }

Now, we will add another action method which is the redirect method which we will redirect after you enter your LinkedIn id and password on the LinkedIn login screen and authentication is successful. then it will redirect to the method. You have to pass the URL of this method in redirect uri as a parameter. This must also be added when creating LinkedIn client id and client secret key.

        public ActionResult RedirectLinkedIN(string code)
        {
            try
            {
                var results = LinkedinLogin.LinkedinPackage.GetLinkedinUserProfile(code, "clientId", "clientSecet", "redirectUri");
                var result = LinkedinLogin.LinkedinPackage.GetLinkedinUserProfile(code, "7710pzu5onereeicxs", "xUvKfIranere45Z0KDa50", "http://localhost:8080/Home/RedirectLinkedIN");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return View();
        }

Now, the URL that we set in the viewing in the first step will be used like this on the view. When you will click on this anchor button it will redirect to the LinkedIn Login screen where you will authenticate your user.

 @{
    ViewBag.Title = "Home Page";
}
<a style="margin-top:10px" href="@ViewBag.url"
   class="btn btn-primary"> Hureee!Login with LinkedIN</a>

Now, run the application and you will see this button. Click on this button

You will see this screen on redirect. You can also face an error if Redirect URI in the app doesn't match the one passed in the code. If everything is fine you will see this screen. Enter the details and click on Sign in.

Now, it will redirect to the method which we have passed inside the redirect URI. Here you will get the Code parameter in the request sent by LinkedIn.This code will be passed in our second method along with the client id, client secret, and redirect URI. In the result, you can see the LinkedIn profile returned for the logged-in user.

So this is how you can integrate Linkedin Sign In using the LinkedinLogin Nuget package in Asp-Net MVC. If you face any issue you can comment on the article.

S
Shubham Batra
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

Linkedin Sign In using LinkedinLogin Nuget package in Asp-Net MVC
Apr 14, 2023
Convert HTML String To Image In C#
Jul 02, 2022
Integrate Stripe Payment Gateway In ASP.NET Core 8.0
Nov 23, 2023
Integrate Stripe Payment Gateway In ASP.NET Core 7.0
Jul 22, 2023

Comments

Tags

Swagger UI
Swashbuckle
SwashbuckleAspNetCore
Rest API
Postman
Api Testing
ITextSharp
Export to Pdf
AspNet Core
AspNet
C#
View to Pdf in Aspnet
Scheduler
Fibonacci series in Java
Display Fibonacci Series
First C# Program
What is C?
C
C Programming
CodeLobster
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1760
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp Join Us On Facebook
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, India   info@code2night.com

Quick Links
  • Home
  • Blogs
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • XML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • PDF Editor
By Language
  • Angular
  • C
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Built with for developers