Skip to content

Instantly share code, notes, and snippets.

@tonyxu-io
Last active August 8, 2020 13:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyxu-io/507da2667aa0c1f791634c301284f2a8 to your computer and use it in GitHub Desktop.
Save tonyxu-io/507da2667aa0c1f791634c301284f2a8 to your computer and use it in GitHub Desktop.
Linkedin Login Sample Code #snippet
<!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