LinkedIn Login through Javascript | Codeexecute

LinkedIn Login through Javascript

Requirement- Client Id

// Initialize linkedin API
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
 api_key: CLIENT ID
 authorize: true
 scope: r_basicprofile r_emailaddress
 onLoad: onLinkedInLoad
</script>
<script type="text/javascript">
  // After Authentication of Account
 function onLinkedInLoad() {
 IN.Event.on(IN, "auth", getProfileData);
 }

 //After successfully Login 
 function onSuccess(data) {
 console.log(data);
  
 }

 // Error in API call
 function onError(error) {
 console.log(error);
 }

 // Get the needed Data
 function getProfileData() {
 IN.API.Raw("/people/~:(id,email-address,first-name,last-name,formatted-name)").result(onSuccess).error(onError);
 }
// destroy the session of linkedin
function closeSession(){
 IN.User.logout();
 return true;
}
</script>
<script type="in/Login"></script>

For custom Button

<script type="text/javascript">
//Invoke login window
function liAuth(){
 IN.User.authorize(function(){
 callback();
 });
}
</script>
<input type="button" onclick="liAuth()" value="Login"/>