Skip to main content

LinkedIn Login Button on our asp.net website using Javascript API

Before implement Linkedin login authentication first we need create Linkedin application and need
to get api key from Linkedin for that open this link https://www.linkedin.com/secure/developer once you open that link we have option like “Add New Application” click on it that will display window like this.
Here you need to mention your website url in Website URL field and JavaScript API Domain fields are same.
Once you enter all the details click ok now api key will generate for your application. Now open your application and write the following code in your aspx page
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Linkedin Authentication Login in Asp.net Website</title>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: Your_API_KEY
</script>
</head>
<body>
<form id="form1" runat="server">
<script type="in/Login">
Hello, <?js= firstName ?> <?js= lastName ?>.
</script>
</form>
</body>
</html>
In header section replace Your_API_KEY with your api key. Once we run above code we will get output of Sign in Button like as shown below
Once we click on that button another window will open and it will ask access permission for that application for your details like as shown below
Once you click the Allow access button you will get output like as show below

Hello, Ur-firstName  lastName

In this way we can implement Linkedin authentication for your web application.

Here you need to remember one point that is once you get the output please try to refresh your page for few times you will notice that login button reappears every time, even though you have already logged into the app and granted permission. By default, Linkedin framework will only fetch an OAuth token if the user explicitly clicks a Sign In button. You can override this to auto-login signed in users for that set the option authorize: true, and the framework will automatically fetch an OAuth token if one is available (i.e. if the user has previously authorized your application). For that you need to change header script code like as shown below
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: Your_API_KEY
authorize: true
</script>
In this way we can implement linkedin authentication mechanism for website.

Popular posts from this blog

Creating package in Oracle Database using Toad For Oracle

What are Packages in Oracle Database A package is  a group   of procedures, functions,  variables   and  SQL statements   created as a single unit. It is used to store together related objects. A package has two parts, Package  Specification  and Package Body.

Resolving 'Setup Account Privileges' error while installing SQL Server

A new installation of Microsoft SQL Server 2012 or Microsoft SQL Server 2008 R2 fails You see the following error message when you try to install a new instance of SQL Server 2012 or SQL Server 2008 R2: Rule "Setup account privileges" failed.

Creating Oracle stored Procedures using TOAD for Oracle

In a database management system, a  stored procedure  is a set of Structured Query Language (SQL) statements with an assigned name that's stored in the database in compiled form so that it can be shared by a number of programs. The use of  stored procedures  can be helpful in controlling  access to data, preserving  data integrity  and  improving  productivity.