Anton Dimitrov Anton Dimitrov - 4 months ago 74
Javascript Question

LinkedIn verify user auth token server side

after 1 day of research, I've ended with the following issue. I'm building an web app with ember.js and currently I'm implementing LinkedIn login, using linkedin javascript sdk. The problem that I have is that after I recieve user information (token, email, first name and etc) I need to verify this token on server side in order to grand session. Unfortunately, the documentation is not very clear for me. I can access token ( or kind of a token ) using IN.ENV.auth, but when I try to validate one from both of them, I recieve "invalid request". On the server side I'm using node and a sample code look like that:

var request = require('request');
var options = {
url: ''

The response from the sdk is like that:

anonymous_expires_in: 1800
anonymous_token: "4u948tas123asfK9DJx9HFYJgcsBFlhIFu93gG"
api_key: "API_KEY"
is_set_client_auth_cookie: false
member_id: "4a13sdasFeD"
oauth_expires_in: 1800
oauth_token: "66Dy9V123lL7H823ddl-5L-KVmg184k0dhAaS"

Thanks in advance.


LinkedIn auth tokens granted from the JS SDK and server-side OAuth are not the same.

There is a process documented on LinkedIn's developer website that explains how to exchange a JS token for a REST API/server-side token: