Last active
August 8, 2020 13:23
-
-
Save tonyxu-io/507da2667aa0c1f791634c301284f2a8 to your computer and use it in GitHub Desktop.
Linkedin Login Sample Code #snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Linkedin Demo</title> | |
<meta charset="utf-8"> | |
<script type="text/javascript" src="//platform.linkedin.com/in.js"> | |
api_key: 86012 cynxvvidr | |
onLoad: checkAuthentication | |
authorize: true | |
lang: en_US | |
</script> | |
</head> | |
<body> | |
<div> | |
<button onclick="requestAuthentication()">Login</button> | |
<button onclick="logoutAuthentication()">Logout</button> | |
</div> | |
<div> | |
<button onclick="requestPeopleAPI()">People API</button> | |
<pre id="response"></pre> | |
</div> | |
<script type="text/javascript"> | |
function checkAuthentication() { | |
console.log('User Status:', IN.User.isAuthorized()) | |
} | |
function requestAuthentication() { | |
IN.User.authorize(onSuccessfulAuthentication); | |
} | |
function logoutAuthentication() { | |
IN.User.logout(onLogoutAuthentication); | |
} | |
function onSuccessfulAuthentication() { | |
console.log('User Logged In:', IN.User.isAuthorized()) | |
} | |
function onLogoutAuthentication() { | |
console.log('User Loggout Out:', IN.User.isAuthorized()) | |
} | |
function requestPeopleAPI() { | |
IN.API.Raw('/people/~?format=json').method('GET').body().result(printResponse); | |
} | |
function printResponse(response) { | |
document.getElementById("response").innerHTML = JSON.stringify(response, null, 2) | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment