npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

linkedin-exchange-tokens-debugged

v0.0.1

Published

A simple function to convert from LinkedIn JS API Tokens to long-lived OAuth 1.0 tokens

Readme

linkedin-exchange-tokens

A simple function to exchange the short-lived OAuth2 token provided by the LinkedIn JSAPI to a long-lived OAuth token that can be used by the server to make REST api calls.

This mechanism is described in this linked-in documentation

This module also has a way to make REST API calls to linked in though that can be done using other modules as well.

NPM info

Install

npm install linkedin-exchange-tokens

Usage


   var exchangeTokens = require('linkedin-exchange-tokens');
   var options = {
     'linkedinKey': 'Your Linked In API Key',
     'linkedinSecret': 'Your Linked In API Secret'
   };

   // now assume your browser JS code calls the server with its OAuth2 token
   // alternatively, this could be from OAuth2 passportjs flow

   /*
    * You can get your token easily and with security by following step 1 & 2 of linkedin exchange token tutorial
    * https://developer-programs.linkedin.com/documents/exchange-jsapi-tokens-rest-api-oauth-tokens
    */


   var oauth2Token = '<token from browser JSAPI: for example: IN.ENV.auth.oauth_token>';
   exchangeTokens(options, oauth2Token, function (err, tokenInfo) {
     // now tokenInfo is the oauth1 token info 
     // {
     //   'public': 'auth_token', 
     //   secret: 'oauth_token_secret', 
     //   expires: 'time when token expires'
     // }
     // You can use this to make rest calls as follows

     tokenInfo.api('/v1/people/~/connections, function (err, info) {
       // boom!
     });
   });

You can also make REST calls with this API using OAuth1.0 tokens.


   var exchangeTokens = require('linkedin-exchange-tokens');
   var options = {
     'public': 'Your Linked In API Key',
     'secret': 'Your Linked In API Secret'
   };

   // assume you have saved the tokenInfo from the previous example
   // into the database and want to use it to make REST calls later

   exchangeTokens.makeTokenInfo(options, tokenInfo)
     .api('/v1/people/~/connections', function (err, info) {
        // boom!
     });

Environment variables

You can pass the linked in API key and secret via environment variables instead of via the options parameter.

  • LIN_API_KEY -- set this to the public API key
  • LIN_API_SECRET -- set this to the API secret