LinkedIn: Javascript token and user confirmation on server

I have read a lot of questions / answers about LinkedIn login using javascript login and user validation from the backend. But I didn't find any solutions that worked with the current API.

I realized that the JS token is not the same as the Oauth Token and I don't need to save the token for future use. I only need to verify the user before registering with the website.

Once the user is authenticated, I will ask the main profile user and api-standard-profile-request

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

      

ApiStandardProfile returns me an object with url (like this one https://api.linkedin.com/v1/people/{id_user}

) and an array with headers (like this one name: "x-li-auth-token", value: "name:xxxx"

). I haven't found in the official docs how to use this, but I get every time "Authentication Failed" with status code 200.

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

thank

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

+3


source to share


2 answers


I also faced a lot of issues with the LinkedIn APIs, I recommend that you follow the latest development docs on the Linkedin developer site because LinkedIn has been modified by its developer program significantly after February 2015, so depending on the old APIs will pose a risk .

I believe the following will help you solve the problems,

 

If you only want a generic profile, add this one public-profile-url

as a comma separated parameter to the API.

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

or for siteStandardProfileRequest , use the following API



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

OAuth vs Javascript SDK:

Javascript SDK

  • Pros: Ease of integration, less coding effort, no token management.

  • Cons - does not support iOS

OAuth

  • Pros: platform independent
  • Cons - Token management, More coding effort.
0


source


I had the same problem and the only way I found to use the JS token was to use the oauth_token header rather than the authorization bearer header when requesting anything with the Rest API:

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

      



JS_TOKEN I am reading on frontend from IN.ENV.auth.oauth_token .

0


source







All Articles