Home > Uncategorized > #LinkedIn #OAUTH Login using #PhantomJS

#LinkedIn #OAUTH Login using #PhantomJS

LinkedIn-Logo

Say you wanted to authenticate yourself against a website that used LinkedIn OAuth for authentication, tricky ?, well, not too bad if you are using PhantomJS.

I’ve elided a bit of information below (in bold), since I’m not going to put my LinkedIn password up on this blog 🙂

var page = require(‘webpage’).create();

page.open(‘https://www.linkedin.com/uas/oauth2/authorization?redirect_uri=http://othersite.com&client_id=THEIR CLIENT ID&scope=r_emailaddress%20r_basicprofile&response_type=code&state=THEIR STATE‘, function (status) {
console.log(“opened linkedin page”);
page.evaluate(function() {
var usernameField = “session_key-oauth2SAuthorizeForm”;
var elUsername = document.getElementById(usernameField);
elUsername.value = ‘XXXXX@gmail.com
var passwordField = “session_password-oauth2SAuthorizeForm”;
var elPassword = document.getElementById(passwordField);
elPassword.value=”XXXXXX“;
var elForm = document.querySelector(“form”);
elForm.submit();
});
page.onLoadFinished = function(){
console.log(“Logged in”);
page.render(“linkedin-2.png”);
step2();
};
});

Advertisement
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: