Thursday, August 16, 2012

Integartion of Linkedin Login button in Asp.net Web applications

Linkedinlogintitle
Hi,In this article i would like to explain the procedure of integrating Linkedin Login button in asp.net.In the previous article's i am explained about the integration of facebook login button and intergaton of google login button in asp.net applications Integration of linkedin login button in asp.net applications is very easy compare to previous one.
Please follow the steps.
Linkedin Login 

 

The Overall procedure is divided in to two parts
1.Creating application in Linkedin
2.Integrating login button in Asp.net application

1.Creating application in Linkedin :

 First, We need to create a application in linkedin inorder to get the API Key and API Secret Key
Lets start..

1.First create a account in Linkedin


3.Next,Click on the Add new application link

4.Fill the following fields with necessary data Example:

Company Name : DemoAppsTesting

Application Name : Login Button

Description : Integrating login button in Asp.net applications

Website URL : http://localhost:4613/Linkedin/Default.aspx

Note: you can replace you're actually site url like www.domain.com or use local host for testing Application use: other

Live status : Development

Developer Contact Email : use working email id

Phone : use working mobile no

OAuth Redirect URL : After successfull login user will be redirected to application main page
Ex: http://localhost:4613/Linkedin/Welcome.aspx

Agreement Language:Browser Locale Setting is recommended

Select the Terms and conditions checkbox and click on Add application button

That's it you have successfully created the application

Now you will get the Oauth Keys

OAuth Keys

API Key: aaaaaaaaaa

Secret Key: ssssssssss

Note: Don't share this secret with anyone.

That's it.First part is successfully completed.

Now its time for login button integration in Asp.net application

First,Select one new Asp.net website and Add two forms

1.Default.aspx

2.Welcome.aspx

Next,Open the design mode of Default.aspx form

Next,Drag and drop one button from Toolbox.

Next,Change the Properties of the button

Text : Login

ID:btnLogin

Add click event for the button

Next,Open the Default.aspx.cs page and write the following code

Next,Add the following line code before the page load

private oAuthLinkedIn _oauth = new oAuthLinkedIn();

Next, Copy the following code in the page load :

protected void Page_Load(object sender, EventArgs e)
    {
        string oauth_token = Request.QueryString["oauth_token"];
        string oauth_verifier = Request.QueryString["oauth_verifier"];
        if (oauth_token != null && oauth_verifier != null)
        {           
            Application["oauth_token"] = oauth_token;
            Application["oauth_verifier"] = oauth_verifier;
        }
    }

Next,Copy the following code in the button click event :

protected void btn_linkedinLogin_Click(object sender, EventArgs e)
    {
        string authLink = _oauth.AuthorizationLinkGet();
        Application["reuqestToken"] = _oauth.Token;
        Application["reuqestTokenSecret"] = _oauth.TokenSecret;
        Application["oauthLink"] = authLink;      
       
        Response.Redirect(authLink);
        
    }

That's it you almost done..Now coming to the important part of the Task.
That is Adding secret key and API Key in application 

Open the Web config file,Add the following code

 
  
  


 
That's it.We have successfully integrated the login button .Now its time for testing 

Labels: , , ,