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-auth-server-openid

v1.0.3

Published

server side api interaction in linkedin auth using openid

Readme

linkedin-auth-server-openid

linkedin-auth-server-openid is a Node.js library designed for server-side integration with LinkedIn's OAuth 2.0 authentication process. It allows you to retrieve user data from LinkedIn once you receive the authorization code from the client side.

This library complements the client-side package react-linkedin-login-openid, which provides a React component for LinkedIn login and sending the authorization code to your server.

Features

  • Simple server-side integration for LinkedIn OpenID Connect.
  • Fetch user data using LinkedIn's API.
  • Designed to work seamlessly with react-linkedin-login-openid.

Installation

npm install linkedin-auth-server-openid

Usage

Import and Initialize

Import the Linkedin class from the package and create an instance by providing your LinkedIn app credentials and redirect URI.

import Linkedin from "linkedin-auth-server-openid";

const linkedin = new Linkedin(
  "your-client-id", // LinkedIn app client ID
  "your-client-secret", // LinkedIn app client secret
  "http://localhost:5173/linked_in_auth_resp" // Redirect URI
);

API Integration

Use the getData method to retrieve user data from LinkedIn. This method requires the authorization code, which you can receive in the request body from the client side.

app.post("/login", async (req, res) => {
  try {
    const authCode = req.body.code; // Authorization code from client
    const { success, userData } = await linkedin.getData(authCode);
    if (success) {
      res.json(userData); // Send the user data back to the client
    } else {
      res.status(400).json({ error: "Failed to fetch user data" });
    }
  } catch (error) {
    res.status(500).json({ error: "Internal Server Error" });
  }
});

Example

Here's a complete example of setting up a server with Express:

import express from "express";
import bodyParser from "body-parser";
import Linkedin from "linkedin-auth-server-openid";

const app = express();
const PORT = 3000;

app.use(bodyParser.json());

const linkedin = new Linkedin(
  "your-client-id",
  "your-client-secret",
  "http://localhost:5173/linked_in_auth_resp"
);

app.post("/login", async (req, res) => {
  try {
    const authCode = req.body.code;
    const { success, userData } = await linkedin.getData(authCode);
    if (success) {
      // Example: Save userData to the database
      // await database.saveUser(userData);
      res.json(userData);
    } else {
      res.status(400).json({ error: "Failed to fetch user data" });
    }
  } catch (error) {
    res.status(500).json({ error: "Internal Server Error" });
  }
});

app.listen(PORT, () => {
  console.log(`Server running on http://localhost:${PORT}`);
});

Parameters

Linkedin Constructor

| Parameter | Type | Description | |------------------|--------|-------------------------------------------------| | client_id | string | Your LinkedIn app's client ID. | | client_secret | string | Your LinkedIn app's client secret. | | redirect_uri | string | The redirect URI configured in your LinkedIn app settings. |

getData(authCode)

  • authCode (string): The authorization code received from the client-side login flow.
  • Returns: A promise that resolves with an object:
    {
      success: boolean,
      userData?: any
    }

Client-Side Integration

To implement the client-side login flow, refer to the react-linkedin-login-openid package. This package provides a React component for LinkedIn login and the ability to send the authorization code to your server.

Notes

  • Ensure your LinkedIn app is properly configured with the correct redirect URI.
  • Use HTTPS in production for secure communication.

Contributions and feedback are welcome! If you encounter any issues, feel free to open an issue or submit a pull request.