{"id":2789,"date":"2017-09-25T19:52:02","date_gmt":"2017-09-25T19:52:02","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=2789"},"modified":"2017-09-25T19:55:46","modified_gmt":"2017-09-25T19:55:46","slug":"login-with-linkedin-using-javascript-sdk","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/","title":{"rendered":"Login with LinkedIn using JavaScript SDK"},"content":{"rendered":"<p>LinkedIn is world&#8217;s most popular social network for professionals. LinkedIn provides various API to enhance the sign-in experience on the web application. If you want to integrate login system on your website, <b>Login with LinkedIn<\/b> is an easiest and powerful way to do that. <b>Sign in with LinkedIn<\/b> feature allow users to log in with their LinkedIn account without creating a new account on your website. It helps to reduce time and cost to implement login system and get more sign-ups.<\/p>\n<p><b>LinkedIn&#8217;s JavaScript SDK<\/b> is a convenient way to implement user login with LinkedIn account on a single page without page refresh. In this tutorial, we will show you how to integrate <b>Login with LinkedIn using JavaScript SDK<\/b>. In this example script, we will authenticate the user with their LinkedIn account and retrieve the user profile data from LinkedIn using JavaScript SDK.<\/p>\n<h2>Create LinkedIn App<\/h2>\n<p>You need to register an application with LinkedIn for using JavaScript SDK. If you have not already registered, <a href=\"https:\/\/www.linkedin.com\/secure\/developer?newapp=\" target=\"_blank\">create a LinkedIn application<\/a> first.<br \/>\nDo you want a step-by-step guide to creating a LinkedIn app? Go through this tutorial &#8211; <a href=\"https:\/\/www.codexworld.com\/create-linkedin-app-client-id-secret\/\">How to Create LinkedIn App<\/a><\/p>\n<p>If you have an existing application, do the following settings to use JavaScript SDK.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Select your App on <a href=\"https:\/\/www.linkedin.com\/developer\/apps\" target=\"_blank\">My Apps<\/a> page.<\/li>\n<li>Click the <b>JavaScript<\/b> link from left menu panel.<\/li>\n<li>Under the <b>JavaScript Settings<\/b> specify the <b>Valid SDK Domains<\/b>. Click the <b>Update<\/b> button.\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-valid-domain-settings-codexworld.png\" alt=\"linkedin-login-javascript-sdk-app-valid-domain-settings-codexworld\" width=\"712\" height=\"267\" class=\"alignnone size-full wp-image-2790\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-valid-domain-settings-codexworld.png 712w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-valid-domain-settings-codexworld-300x113.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-valid-domain-settings-codexworld-200x75.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-valid-domain-settings-codexworld-346x130.png 346w\" sizes=\"auto, (max-width: 712px) 100vw, 712px\" \/><\/div>\n<p>Note that: To test on localhost add this domain &#8211; <code>http:\/\/localhost<\/code>\n<\/li>\n<\/ul>\n<p>Go to the <b>Authentication<\/b> page, copy and keep the <b>Client ID<\/b> for later use in the script.<\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-client-id-codexworld.png\" alt=\"linkedin-login-javascript-sdk-app-client-id-codexworld\" width=\"837\" height=\"309\" class=\"alignnone size-full wp-image-2791\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-client-id-codexworld.png 837w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-client-id-codexworld-300x111.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-client-id-codexworld-768x284.png 768w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-client-id-codexworld-200x74.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/linkedin-login-javascript-sdk-app-client-id-codexworld-346x128.png 346w\" sizes=\"auto, (max-width: 837px) 100vw, 837px\" \/><\/div>\n<h2>JavaScript<\/h2>\n<p>In order to use SDK functionality, include the LinkedIn JavaScript library in your web page and specify your LinkedIn App API Key.<\/p>\n<pre>&lt;<span style=\"color:#bf4f24\">script<\/span> <span style=\"color:#bf4f24\">type<\/span>=<span style=\"color:#0b6125\">\"text\/javascript\"<\/span> <span style=\"color:#bf4f24\">src<\/span>=<span style=\"color:#0b6125\">\"\/\/platform.linkedin.com\/in.js\"<\/span>>\r\n    api_key: App_Client_ID\r\n    authorize: <span style=\"color:#811f24;font-weight:700\">true<\/span>\r\n    <span style=\"color:#693a17\">onLoad<\/span>: onLinkedInLoad\r\n    scope: r_basicprofile r_emailaddress\r\n&lt;\/<span style=\"color:#bf4f24\">script<\/span>>\r\n<\/pre>\n<p>The following JavaScript methods are used to integrate LinkedIn login process on a single page.<\/p>\n<ul class=\"bullet_disk_list\">\n<li><code>onLinkedInLoad()<\/code> &#8211; Setup an event listener to make an API call once auth is complete.<\/li>\n<li><code>getProfileData()<\/code> &#8211; Use the API call to request the member&#8217;s profile data.<\/li>\n<li><code>displayProfileData()<\/code> &#8211; Display member profile information in the webpage.<\/li>\n<li><code>logout()<\/code> &#8211; Log the user out from LinkedIn account.<\/li>\n<li><code>removeProfileData()<\/code> &#8211; Hide profile information from the web page.<\/li>\n<\/ul>\n<pre>&lt;<span style=\"color:#bf4f24\">script<\/span> <span style=\"color:#bf4f24\">type<\/span>=<span style=\"color:#0b6125\">\"text\/javascript\"<\/span>>\r\n    <span style=\"color:#5a525f;font-style:italic\">\/\/ Setup an event listener to make an API call once auth is complete<\/span>\r\n    <span style=\"color:#a71d5d;font-style:italic\">function<\/span> <span style=\"color:#bf4f24\">onLinkedInLoad<\/span>() {\r\n        IN.Event.on(IN, <span style=\"color:#0b6125\">\"auth\"<\/span>, getProfileData);\r\n    }\r\n    \r\n    <span style=\"color:#5a525f;font-style:italic\">\/\/ Use the API call wrapper to request the member's profile data<\/span>\r\n    <span style=\"color:#a71d5d;font-style:italic\">function<\/span> <span style=\"color:#bf4f24\">getProfileData<\/span>() {\r\n        IN.API.Profile(<span style=\"color:#0b6125\">\"me\"<\/span>).fields(<span style=\"color:#0b6125\">\"id\"<\/span>, <span style=\"color:#0b6125\">\"first-name\"<\/span>, <span style=\"color:#0b6125\">\"last-name\"<\/span>, <span style=\"color:#0b6125\">\"headline\"<\/span>, <span style=\"color:#0b6125\">\"location\"<\/span>, <span style=\"color:#0b6125\">\"picture-url\"<\/span>, <span style=\"color:#0b6125\">\"public-profile-url\"<\/span>, <span style=\"color:#0b6125\">\"email-address\"<\/span>).result(displayProfileData)<span style=\"color:#693a17\">.error<\/span>(<span style=\"color:#693a17\">onError<\/span>);\r\n    }\r\n\r\n    <span style=\"color:#5a525f;font-style:italic\">\/\/ Handle the successful return from the API call<\/span>\r\n    <span style=\"color:#a71d5d;font-style:italic\">function<\/span> <span style=\"color:#bf4f24\">displayProfileData<\/span>(data){\r\n        <span style=\"color:#a71d5d;font-style:italic\">var<\/span> user <span style=\"color:#794938\">=<\/span> data.values[<span style=\"color:#811f24;font-weight:700\">0<\/span>];\r\n        <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"picture\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> <span style=\"color:#0b6125\">'&lt;img src=\"'<\/span><span style=\"color:#794938\">+<\/span>user.pictureUrl<span style=\"color:#794938\">+<\/span><span style=\"color:#0b6125\">'\" \/>'<\/span>;\r\n        <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"name\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> user.firstName<span style=\"color:#794938\">+<\/span><span style=\"color:#0b6125\">' '<\/span><span style=\"color:#794938\">+<\/span>user.lastName;\r\n        <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"intro\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> user.headline;\r\n        <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"email\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> user.emailAddress;\r\n        <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"location\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> user.<span style=\"color:#b4371f\">location<\/span>.<span style=\"color:#b4371f\">name<\/span>;\r\n        <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"link\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> <span style=\"color:#0b6125\">'&lt;a href=\"'<\/span><span style=\"color:#794938\">+<\/span>user.publicProfileUrl<span style=\"color:#794938\">+<\/span><span style=\"color:#0b6125\">'\" target=\"_blank\">Visit profile&lt;\/a>'<\/span>;\r\n        <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">'profileData'<\/span>).<span style=\"color:#b4371f\">style<\/span>.<span style=\"color:#b4371f\">display<\/span> <span style=\"color:#794938\">=<\/span> <span style=\"color:#0b6125\">'block'<\/span>;\r\n    }\r\n\r\n    <span style=\"color:#5a525f;font-style:italic\">\/\/ Handle an error response from the API call<\/span>\r\n    <span style=\"color:#a71d5d;font-style:italic\">function<\/span> <span style=\"color:#bf4f24\">onError<\/span>(error) {\r\n        <span style=\"color:#bf4f24\">console<\/span><span style=\"color:#693a17\">.log<\/span>(error);\r\n    }\r\n    \r\n    <span style=\"color:#5a525f;font-style:italic\">\/\/ Destroy the session of linkedin<\/span>\r\n    <span style=\"color:#a71d5d;font-style:italic\">function<\/span> <span style=\"color:#bf4f24\">logout<\/span>(){\r\n        IN.User.logout(removeProfileData);\r\n    }\r\n    \r\n    <span style=\"color:#5a525f;font-style:italic\">\/\/ Remove profile data from page<\/span>\r\n    <span style=\"color:#a71d5d;font-style:italic\">function<\/span> <span style=\"color:#bf4f24\">removeProfileData<\/span>(){\r\n        <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">'profileData'<\/span>).<span style=\"color:#693a17\">remove<\/span>();\r\n    }\r\n&lt;\/<span style=\"color:#bf4f24\">script<\/span>>\r\n<\/pre>\n<h2>HTML<\/h2>\n<p>Create the <b>Sign In with LinkedIn<\/b> button.<\/p>\n<pre><span style=\"color:#5a525f;font-style:italic\">&lt;!-- sign in with linkedin button --><\/span>\r\n&lt;<span style=\"color:#bf4f24\">script<\/span> <span style=\"color:#bf4f24\">type<\/span>=<span style=\"color:#0b6125\">\"in\/Login\"<\/span>>&lt;\/<span style=\"color:#bf4f24\">script<\/span>>\r\n<\/pre>\n<p>Display the member&#8217;s profile data (picture, first name, last name, email address, headline, location, and public profile URL). Also, a logout link will be provided for logout the user from the LinkedIn account.<\/p>\n<pre><span style=\"color:#5a525f;font-style:italic\">&lt;!-- display profile info --><\/span>\r\n&lt;<span style=\"color:#bf4f24\">div<\/span> <span style=\"color:#bf4f24\">id<\/span><span style=\"color:#794938\">=<\/span><span style=\"color:#0b6125\">\"profileData\"<\/span> <span style=\"color:#bf4f24\">style<\/span>=<span style=\"color:#0b6125\">\"display: none;\"<\/span>>\r\n    &lt;<span style=\"color:#bf4f24\">p<\/span>>&lt;<span style=\"color:#bf4f24\">a<\/span> <span style=\"color:#bf4f24\">href<\/span>=<span style=\"color:#0b6125\">\"javascript:void(0);\"<\/span> <span style=\"color:#bf4f24\">onclick<\/span>=<span style=\"color:#0b6125\">\"logout()\"<\/span>>Logout&lt;\/<span style=\"color:#bf4f24\">a<\/span>>&lt;\/<span style=\"color:#bf4f24\">p<\/span>>\r\n    &lt;<span style=\"color:#bf4f24\">div<\/span> <span style=\"color:#bf4f24\">id<\/span><span style=\"color:#794938\">=<\/span><span style=\"color:#0b6125\">\"picture\"<\/span>>&lt;\/<span style=\"color:#bf4f24\">div<\/span>>\r\n    &lt;<span style=\"color:#bf4f24\">div<\/span> <span style=\"color:#bf4f24\">class<\/span>=<span style=\"color:#0b6125\">\"info\"<\/span>>\r\n        &lt;<span style=\"color:#bf4f24\">p<\/span> <span style=\"color:#bf4f24\">id<\/span><span style=\"color:#794938\">=<\/span><span style=\"color:#0b6125\">\"name\"<\/span>>&lt;\/<span style=\"color:#bf4f24\">p<\/span>>\r\n        &lt;<span style=\"color:#bf4f24\">p<\/span> <span style=\"color:#bf4f24\">id<\/span><span style=\"color:#794938\">=<\/span><span style=\"color:#0b6125\">\"intro\"<\/span>>&lt;\/<span style=\"color:#bf4f24\">p<\/span>>\r\n        &lt;<span style=\"color:#bf4f24\">p<\/span> <span style=\"color:#bf4f24\">id<\/span><span style=\"color:#794938\">=<\/span><span style=\"color:#0b6125\">\"email\"<\/span>>&lt;\/<span style=\"color:#bf4f24\">p<\/span>>\r\n        &lt;<span style=\"color:#bf4f24\">p<\/span> <span style=\"color:#bf4f24\">id<\/span><span style=\"color:#794938\">=<\/span><span style=\"color:#0b6125\">\"location\"<\/span>>&lt;\/<span style=\"color:#bf4f24\">p<\/span>>\r\n        &lt;<span style=\"color:#bf4f24\">p<\/span> <span style=\"color:#bf4f24\">id<\/span><span style=\"color:#794938\">=<\/span><span style=\"color:#0b6125\">\"link\"<\/span>>&lt;\/<span style=\"color:#bf4f24\">p<\/span>>\r\n    &lt;\/<span style=\"color:#bf4f24\">div<\/span>>\r\n&lt;\/<span style=\"color:#bf4f24\">div<\/span>>\r\n<\/pre>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/login-with-linkedin-using-php\/\">Login with LinkedIn using PHP<\/a><\/span><\/p>\n<h2>Save User Data to the Database (jQuery, Ajax, PHP, and MySQL)<\/h2>\n<p>After user logged in via LinkedIn JavaScript SDK, if you want to store the user profile information into the MySQL database, follow the below steps.<\/p>\n<p><b>Create Database Table<\/b><br \/>\nTo store user profile information a table needs to be created in the database. The following SQL creates a <code>users<\/code> table with some basic columns in the MySQL database.<\/p>\n<pre><span style=\"color:#794938\">CREATE<\/span> <span style=\"color:#794938\">TABLE<\/span> `<span style=\"color:#bf4f24\">users<\/span>` (\r\n <span style=\"color:#0b6125\">`id`<\/span> <span style=\"color:#a71d5d;font-style:italic\">int<\/span>(<span style=\"color:#811f24;font-weight:700\">11<\/span>) <span style=\"color:#794938\">NOT NULL<\/span> AUTO_INCREMENT,\r\n <span style=\"color:#0b6125\">`oauth_provider`<\/span> enum(<span style=\"color:#0b6125\">''<\/span>,<span style=\"color:#0b6125\">'linkedin'<\/span>) COLLATE utf8_unicode_ci <span style=\"color:#794938\">NOT NULL<\/span>,\r\n <span style=\"color:#0b6125\">`oauth_uid`<\/span> <span style=\"color:#a71d5d;font-style:italic\">varchar<\/span>(<span style=\"color:#811f24;font-weight:700\">100<\/span>) COLLATE utf8_unicode_ci <span style=\"color:#794938\">NOT NULL<\/span>,\r\n <span style=\"color:#0b6125\">`first_name`<\/span> <span style=\"color:#a71d5d;font-style:italic\">varchar<\/span>(<span style=\"color:#811f24;font-weight:700\">50<\/span>) COLLATE utf8_unicode_ci <span style=\"color:#794938\">NOT NULL<\/span>,\r\n <span style=\"color:#0b6125\">`last_name`<\/span> <span style=\"color:#a71d5d;font-style:italic\">varchar<\/span>(<span style=\"color:#811f24;font-weight:700\">50<\/span>) COLLATE utf8_unicode_ci <span style=\"color:#794938\">NOT NULL<\/span>,\r\n <span style=\"color:#0b6125\">`email`<\/span> <span style=\"color:#a71d5d;font-style:italic\">varchar<\/span>(<span style=\"color:#811f24;font-weight:700\">100<\/span>) COLLATE utf8_unicode_ci <span style=\"color:#794938\">NOT NULL<\/span>,\r\n <span style=\"color:#0b6125\">`location`<\/span> <span style=\"color:#a71d5d;font-style:italic\">varchar<\/span>(<span style=\"color:#811f24;font-weight:700\">255<\/span>) COLLATE utf8_unicode_ci <span style=\"color:#794938\">NOT NULL<\/span>,\r\n <span style=\"color:#0b6125\">`picture`<\/span> <span style=\"color:#a71d5d;font-style:italic\">varchar<\/span>(<span style=\"color:#811f24;font-weight:700\">255<\/span>) COLLATE utf8_unicode_ci <span style=\"color:#794938\">NOT NULL<\/span>,\r\n <span style=\"color:#0b6125\">`profile_url`<\/span> <span style=\"color:#a71d5d;font-style:italic\">varchar<\/span>(<span style=\"color:#811f24;font-weight:700\">255<\/span>) COLLATE utf8_unicode_ci <span style=\"color:#794938\">NOT NULL<\/span>,\r\n <span style=\"color:#0b6125\">`created`<\/span> datetime <span style=\"color:#794938\">NOT NULL<\/span>,\r\n <span style=\"color:#0b6125\">`modified`<\/span> datetime <span style=\"color:#794938\">NOT NULL<\/span>,\r\n <span style=\"color:#a71d5d;font-style:italic\">PRIMARY KEY<\/span> (<span style=\"color:#0b6125\">`id`<\/span>)\r\n) ENGINE<span style=\"color:#794938\">=<\/span>InnoDB DEFAULT CHARSET<span style=\"color:#794938\">=<\/span>utf8 COLLATE<span style=\"color:#794938\">=<\/span>utf8_unicode_ci;\r\n<\/pre>\n<p><b>JavaScript<\/b><br \/>\nWe will use jQuery and Ajax to send the user profile data to the PHP script (<code>saveUserData.php<\/code>) and insert the profile information into the MySQL database.<\/p>\n<p>At first, include the jQuery library.<\/p>\n<pre>&lt;<span style=\"color:#bf4f24\">script<\/span> <span style=\"color:#bf4f24\">src<\/span>=<span style=\"color:#0b6125\">\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.2.1\/jquery.min.js\"<\/span>>&lt;\/<span style=\"color:#bf4f24\">script<\/span>>\r\n<\/pre>\n<p>The <code>saveUserData()<\/code> function posts the user profile data to <code>saveUserData.php<\/code> file using jQuery Ajax.<\/p>\n<pre><span style=\"color:#5a525f;font-style:italic\">\/\/ Save user data to the database<\/span>\r\n<span style=\"color:#a71d5d;font-style:italic\">function<\/span> <span style=\"color:#bf4f24\">saveUserData<\/span>(userData){\r\n    <span style=\"color:#794938\">$<\/span><span style=\"color:#693a17\">.post<\/span>(<span style=\"color:#0b6125\">'saveUserData.php'<\/span>, {oauth_provider:<span style=\"color:#0b6125\">'linkedin'<\/span>,userData: JSON.stringify(userData)}, <span style=\"color:#a71d5d;font-style:italic\">function<\/span>(data){ <span style=\"color:#794938\">return<\/span> <span style=\"color:#811f24;font-weight:700\">true<\/span>; });\r\n}\r\n<\/pre>\n<p>Place the <code>saveUserData()<\/code> function in the <code>displayProfileData()<\/code> method to save user profile data in the database.<\/p>\n<pre><span style=\"color:#5a525f;font-style:italic\">\/\/ Handle the successful return from the API call<\/span>\r\n<span style=\"color:#a71d5d;font-style:italic\">function<\/span> <span style=\"color:#bf4f24\">displayProfileData<\/span>(data){\r\n    <span style=\"color:#a71d5d;font-style:italic\">var<\/span> user <span style=\"color:#794938\">=<\/span> data.values[<span style=\"color:#811f24;font-weight:700\">0<\/span>];\r\n    <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"picture\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> <span style=\"color:#0b6125\">'&lt;img src=\"'<\/span><span style=\"color:#794938\">+<\/span>user.pictureUrl<span style=\"color:#794938\">+<\/span><span style=\"color:#0b6125\">'\" \/>'<\/span>;\r\n    <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"name\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> user.firstName<span style=\"color:#794938\">+<\/span><span style=\"color:#0b6125\">' '<\/span><span style=\"color:#794938\">+<\/span>user.lastName;\r\n    <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"intro\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> user.headline;\r\n    <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"email\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> user.emailAddress;\r\n    <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"location\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> user.<span style=\"color:#b4371f\">location<\/span>.<span style=\"color:#b4371f\">name<\/span>;\r\n    <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">\"link\"<\/span>).innerHTML <span style=\"color:#794938\">=<\/span> <span style=\"color:#0b6125\">'&lt;a href=\"'<\/span><span style=\"color:#794938\">+<\/span>user.publicProfileUrl<span style=\"color:#794938\">+<\/span><span style=\"color:#0b6125\">'\" target=\"_blank\">Visit profile&lt;\/a>'<\/span>;\r\n    <span style=\"color:#691c97\">document<\/span>.<span style=\"color:#693a17\">getElementById<\/span>(<span style=\"color:#0b6125\">'profileData'<\/span>).<span style=\"color:#b4371f\">style<\/span>.<span style=\"color:#b4371f\">display<\/span> <span style=\"color:#794938\">=<\/span> <span style=\"color:#0b6125\">'block'<\/span>;\r\n    \r\n    <span style=\"color:#5a525f;font-style:italic\">\/\/ Save user data<\/span>\r\n    saveUserData(user);\r\n}\r\n<\/pre>\n<p><b>Database Configuration (dbConfig.php)<\/b><br \/>\nThe <code>dbConfig.php<\/code> file is used to connect and select the MySQL database.<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php<br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Database&nbsp;configuration<br \/><\/span><span style=\"color: #0000BB\">$dbHost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"localhost\"<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">$dbUsername&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"root\"<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">$dbPassword&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"*****\"<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">$dbName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"codexworld\"<\/span><span style=\"color: #007700\">;<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/Create&nbsp;connection&nbsp;and&nbsp;select&nbsp;DB<br \/><\/span><span style=\"color: #0000BB\">$db&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">mysqli<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$dbHost<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbUsername<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbPassword<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbName<\/span><span style=\"color: #007700\">);<br \/><br \/>if&nbsp;(<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">)&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;die(<\/span><span style=\"color: #DD0000\">\"Unable&nbsp;to&nbsp;connect&nbsp;database:&nbsp;\"&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">);<br \/>}<br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<p><b>Insert User Data to the Database (saveUserData.php)<\/b><br \/>\nAt first, JSON data would be decoded and stored into PHP variable (<code>$userData<\/code>). Before inserting the data in the <code>users<\/code> table, we will check whether the user already exists in the database and insert or update the user data.<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php<br \/><\/span><span style=\"color: #FF8000\">\/\/Load&nbsp;the&nbsp;database&nbsp;configuration&nbsp;file<br \/><\/span><span style=\"color: #007700\">include&nbsp;<\/span><span style=\"color: #DD0000\">'dbConfig.php'<\/span><span style=\"color: #007700\">;<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/Convert&nbsp;JSON&nbsp;data&nbsp;into&nbsp;PHP&nbsp;variable<br \/><\/span><span style=\"color: #0000BB\">$userData&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'userData'<\/span><span style=\"color: #007700\">]);<br \/>if(!empty(<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">)){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$oauth_provider&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'oauth_provider'<\/span><span style=\"color: #007700\">];<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Check&nbsp;whether&nbsp;user&nbsp;data&nbsp;already&nbsp;exists&nbsp;in&nbsp;database<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$prevQuery&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"SELECT&nbsp;*&nbsp;FROM&nbsp;users&nbsp;WHERE&nbsp;oauth_provider&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$oauth_provider<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"'&nbsp;AND&nbsp;oauth_uid&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">id<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"'\"<\/span><span style=\"color: #007700\">;<br \/><br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$prevResult&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$prevQuery<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">$prevResult<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">num_rows&nbsp;<\/span><span style=\"color: #007700\">&gt;&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Update&nbsp;user&nbsp;data&nbsp;if&nbsp;already&nbsp;exists<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$query&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"UPDATE&nbsp;users&nbsp;SET&nbsp;first_name&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">firstName<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;last_name&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">lastName<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;email&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">emailAddress<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;location&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">location<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">name<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;picture&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">picture<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">pictureUrl<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;profile_url&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">publicProfileUrl<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;modified&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">date<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"Y-m-d&nbsp;H:i:s\"<\/span><span style=\"color: #007700\">).<\/span><span style=\"color: #DD0000\">\"'&nbsp;WHERE&nbsp;oauth_provider&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$oauth_provider<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"'&nbsp;AND&nbsp;oauth_uid&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">id<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"'\"<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$update&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$query<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;}else{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Insert&nbsp;user&nbsp;data<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$query&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"INSERT&nbsp;INTO&nbsp;users&nbsp;SET&nbsp;oauth_provider&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$oauth_provider<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;oauth_uid&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">id<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;first_name&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">firstName<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;last_name&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">lastName<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;email&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">emailAddress<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;location&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">location<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">name<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;picture&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">pictureUrl<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;profile_url&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$userData<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">publicProfileUrl<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"',&nbsp;created&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">date<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"Y-m-d&nbsp;H:i:s\"<\/span><span style=\"color: #007700\">).<\/span><span style=\"color: #DD0000\">\"',&nbsp;modified&nbsp;=&nbsp;'\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">date<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"Y-m-d&nbsp;H:i:s\"<\/span><span style=\"color: #007700\">).<\/span><span style=\"color: #DD0000\">\"'\"<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$insert&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$query<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>}<br \/>die(<\/span><span style=\"color: #DD0000\">'success'<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>Conclusion<\/h2>\n<p>LinkedIn JavaScript SDK is very useful when you want to implement login system on a single page without page refresh. Using our example code you can easily retrieve the user&#8217;s profile information from LinkedIn and store data in your database. If you want to use PHP client library instead of JavaScript SDK, follow this tutorial &#8211; <a href=\"https:\/\/www.codexworld.com\/login-with-linkedin-using-php\/\">Login with LinkedIn using PHP<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>LinkedIn is world&#8217;s most popular social network for professionals. LinkedIn provides various API to enhance the sign-in experience on the web application. If you want to integrate login system on your website, Login with LinkedIn <\/p>\n","protected":false},"author":1,"featured_media":2792,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[301],"tags":[66,19,14,133],"class_list":["post-2789","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linkedin","tag-javascript","tag-mysql","tag-php","tag-social-login","cat-301-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Login with LinkedIn using JavaScript SDK - CodexWorld<\/title>\n<meta name=\"description\" content=\"Login with LinkedIn on a single page without page refresh using JavaScript SDK. Example script to integrate sign in with LinkedIn using JavaScript API and save user data to database using jQuery, Ajax, PHP and MySQL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Login with LinkedIn using JavaScript SDK - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Login with LinkedIn on a single page without page refresh using JavaScript SDK. Example script to integrate sign in with LinkedIn using JavaScript API and save user data to database using jQuery, Ajax, PHP and MySQL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-25T19:52:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-09-25T19:55:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Login with LinkedIn using JavaScript SDK\",\"datePublished\":\"2017-09-25T19:52:02+00:00\",\"dateModified\":\"2017-09-25T19:55:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/\"},\"wordCount\":649,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png\",\"keywords\":[\"JavaScript\",\"MySQL\",\"PHP\",\"Social Login\"],\"articleSection\":[\"LinkedIn\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/\",\"name\":\"Login with LinkedIn using JavaScript SDK - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png\",\"datePublished\":\"2017-09-25T19:52:02+00:00\",\"dateModified\":\"2017-09-25T19:55:46+00:00\",\"description\":\"Login with LinkedIn on a single page without page refresh using JavaScript SDK. Example script to integrate sign in with LinkedIn using JavaScript API and save user data to database using jQuery, Ajax, PHP and MySQL.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png\",\"width\":1366,\"height\":768},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/login-with-linkedin-using-javascript-sdk\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Login with LinkedIn using JavaScript SDK\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Login with LinkedIn using JavaScript SDK - CodexWorld","description":"Login with LinkedIn on a single page without page refresh using JavaScript SDK. Example script to integrate sign in with LinkedIn using JavaScript API and save user data to database using jQuery, Ajax, PHP and MySQL.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/","og_locale":"en_US","og_type":"article","og_title":"Login with LinkedIn using JavaScript SDK - CodexWorld","og_description":"Login with LinkedIn on a single page without page refresh using JavaScript SDK. Example script to integrate sign in with LinkedIn using JavaScript API and save user data to database using jQuery, Ajax, PHP and MySQL.","og_url":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2017-09-25T19:52:02+00:00","article_modified_time":"2017-09-25T19:55:46+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Login with LinkedIn using JavaScript SDK","datePublished":"2017-09-25T19:52:02+00:00","dateModified":"2017-09-25T19:55:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/"},"wordCount":649,"commentCount":0,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png","keywords":["JavaScript","MySQL","PHP","Social Login"],"articleSection":["LinkedIn"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/","url":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/","name":"Login with LinkedIn using JavaScript SDK - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png","datePublished":"2017-09-25T19:52:02+00:00","dateModified":"2017-09-25T19:55:46+00:00","description":"Login with LinkedIn on a single page without page refresh using JavaScript SDK. Example script to integrate sign in with LinkedIn using JavaScript API and save user data to database using jQuery, Ajax, PHP and MySQL.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png","width":1366,"height":768},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/login-with-linkedin-using-javascript-sdk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Login with LinkedIn using JavaScript SDK"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/09\/login-sign-in-with-linkedin-javascript-sdk-php-mysql-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-IZ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=2789"}],"version-history":[{"count":8,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2789\/revisions"}],"predecessor-version":[{"id":2800,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2789\/revisions\/2800"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/2792"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=2789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=2789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=2789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}