Integrate Login with LinkedIn oAuth in website using PHP

People like to login into any website using their social network accounts like Facebook, Twitter, Google, LinkedIn. It’s easy because user doesn’t have to fill lengthy forms, confirm their email address. Now many big websites support APIs for users to authenticate and login to any website. Now we are going to learn how users can Login to website using their LinkedIn.Com Account using PHP.

Integrate-Login-with-Linkedin-oAuth-in-website-using-PHP.png

So now here is step by step tutorial on how to integrate login system with LinkedIn API using PHP.

Step 1:

We need to make new application on LinkedIn. Go to http://LinkedIn.com and Create a New Application.


 

Create Application Linkedin


 Step 2:

Fill out the form to register a new application.


Fill LinkedIn Application Details


 Step 3:

Application was created successfully. And copy API Key & Secret Key somewhere because it will be used in Application.


 

Linkedin App Details


 Step 4:

Download the code from above download button. Here is the folder structure for better understanding. We will edit only config.php for our login system to work.

 

images

| — linked-login.png    //user login image

oAuth

| — class.linkedClass.php

| — config.php                        // change the API key, Secret key base URL &

| — linkedinoAuth.php

| — OAuth.php

authorize_success.php

example.php

linkedin.php

 

Step 5:

Edit Config.PHP and insert the API key and secret key that we obtained earlier from LinkedIn.

Change the base_url & callback_url as required.

Step 6:

Now run this demo script on your hosting and open example.php like this. http://yourdomain.com/linkedin/example.php.

This will show you similar page with button for user to click and login with LinkedIn.Com. Now when user clicks the login with LinkedIn button. It will take you to LinkedIn.Com website for authorization. See example below.


 

linkedin login button


 Step 7:

Click Allow Access button. It will redirect user back to authorize_success.php.


 

LinkedIn authorization page


 Step 8:

Now user access credentials can be saved in database for future use. And all information that LinkedIn sends back will be printed on the page by authorize_success.php.

Example screenshot below.


Retured user info from LinkedIn

 


Check Demo:

Please check out demo to understand properly the sequence and working of script.

One Reply to “Integrate Login with LinkedIn oAuth in website using PHP”

  1. Deena says:

    Hi,

    I have SSL connection error .Please help me.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

scroll to top