3

I have been reading a lot of questions/answers about the LinkedIn login through javascript login and the validation of the user from backend. But I didn't find a solution that worked with current API.

I understood that the JS token is not the same as the Oauth Token and I don't need to save the token for the future use, I only need to validate the user before the signup on the website.

Once the user is authenticated, I'm going to request the basic profile user and api-standard-profile-request

IN.API.Profile("me").fields(
        'id', 'first-name', 'last-name', 'email-address', 'api-standard-profile-request')

The apiStandardProfile returns me an object with an url (like this https://api.linkedin.com/v1/people/{id_user}) and an array with headers (like this name: "x-li-auth-token", value: "name:xxxx"). I haven't find in the official docs how to use this, but I receive every time an "Authentication Failed" with status code 200.

So, do I need to rewrite the authentication flow with Oauth2.0, or can I continue to use the Javascript login?

Thanks

P.S.: I found and read the old documentation from this old topic https://web.archive.org/web/20141028192415/https://developer.linkedin.com/documents/exchange-jsapi-tokens-rest-api-oauth-tokens.

2 Answers 2

1

I've had the same problem and the only way I found to use the JS token was to use the header oauth_token instead of an Authorization Bearer header when requesting something with Rest API:

POST https://api.linkedin.com/v1/people/~:(id,firstName,lastName,picture-url,email-address)?format=json
Headers {
  'oauth_token': JS_TOKEN
}

The JS_TOKEN I'm reading on frontend from IN.ENV.auth.oauth_token.

Sign up to request clarification or add additional context in comments.

Comments

0

I have also faced a lot of issues with LinkedIn APIs, I am recommending you to follow the latest development docs in Linkedin's developer site because LinkedIn had been changed their developer programme significantly after Feb 2015, so depending upon the old APIs will be a risk.

I believe following will help you to solve the issues,

If you only need public profile, add this public-profile-url as the comma separated parameter in the API.

https://api.linkedin.com/v1/people/~:(id,num-connections,picture-url,public-profile-url)?format=json

or for siteStandardProfileRequest, use following API

https://api.linkedin.com/v1/people/~?format=json

OAuth vs Javascript SDK:

Javascript SDK

  • Pros: Easy to integrate, less coding effort, no token management.

  • Cons - will not support iOS

OAuth

  • Pros: platform independent
  • Cons - Token managment, More coding effort

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.