Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
OAuthSimple w/ LinkedIn
<title>OAuthSimple w/ LinkedIn</title>
<script src="OAuthSimple.js"></script>
You must edit the two following lines and put in your consumer key and shared secret
var consumer_key = "";
var shared_secret = "";
Nothing below here needs to be edited for the demo to operate
var oauth_info = {};
var oauth = OAuthSimple(consumer_key, shared_secret);
function parse_response(response, callback) {
response.replace(new RegExp("([^?=&]+)(=([^&]*))?", "g"), function($0, $1, $2, $3) { oauth_info[$1] = $3; });;
function authorize_url() {
set_url("" + oauth_info.oauth_token, document.getElementById("au"));
function access_token_url(pin) {
var url = oauth.sign({action: "GET", path: "", parameters: {oauth_verifier: pin}, signatures: oauth_info}).signed_url;
set_url(url, document.getElementById("at"));
function fetch_profile_url() {
var url = oauth.sign({action: "GET", path: "", signatures: oauth_info}).signed_url;
set_url(url, document.getElementById("fp"));
function set_url(url, element) {
element.value = url;
var span = document.createElement("span");
span.innerHTML = "&nbsp;&nbsp;<a href='" + url + "' target='_blank'>Open</a>";
element.parentNode.insertBefore(span, element.nextSibling);
window.onload = function() {
var url = oauth.sign({action: "GET", path: "", parameters: {oauth_callback: "oob"}}).signed_url;
set_url(url, document.getElementById("rt"));
<h1>OAuthSimple w/ LinkedIn</h1>
<label for="rt">Request Token URL:</label> <input type="text" size="100" name="rt" id="rt">
<label for="rtr">Request Token Response:</label><br><textarea rows="5" cols="75" name="rtr" id="rtr"></textarea>
<button onclick="javascript:parse_response(document.getElementById('rtr').value, authorize_url)">Parse Response</button>
<label for="au">Authorize URL:</label> <input type="text" size="100" name="au" id="au">
<label for="vp">Verifier PIN Code:</label> <input type="text" size="100" name="vp" id="vp">
<button onclick="javascript:access_token_url(document.getElementById('vp').value)">Get Access Token URL</button>
<label for="at">Access Token URL:</label> <input type="text" size="100" name="at" id="at">
<label for="atr">Access Token Response:</label><br><textarea rows="5" cols="75" name="atr" id="atr"></textarea>
<button onclick="javascript:parse_response(document.getElementById('atr').value, fetch_profile_url)">Parse Response</button>
<label for="fp">Fetch Profile URL:</label> <input type="text" size="100" name="fp" id="fp">



This code is good but some issue in it.First one is that why it is not showing url directly with access token and second one is that after some modification i am getting some issue-

You have successfully authorized ****

Please return to your application and enter the following security code to grant access:
Why i am getting this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.