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

plex-oauth

v2.1.0

Published

Small library to handle simple OAuth with Plex

Readme

testing codeql

Overview

This library is used to work with Plex OAuth to get an auth token used for making requests to a Plex server's API

As a note, these auth tokens should not be public. If you are making an app using a Plex auth token, it is recommended to not use the auth token on a frontend. If you need to authenticate a frontend system, then you should use the Plex auth token on the backend to make requests to the Plex server and use a different type of authentication for the frontend that will work with the Plex auth token on the backend.

Installation

You can install this package through npm

npm install plex-oauth

Usage

There are only 2 main functions to use in the PlexOauth class (requestHostedLoginURL & checkForAuthToken). These will both return promises. If either of these functions throw an error, it needs to be explicitly caught with a try/catch or using .catch(err) on the promise itself.

Please look at the following example of how to get the Plex hosted login UI URL and how to query for the auth token:

import { PlexOauth, IPlexClientDetails } from "plex-oauth"

let clientInformation: IPlexClientDetails = {
    clientIdentifier: "<PROVIDE_UNIQUE_VALUE>", // This is a unique identifier used to identify your app with Plex.
    product: "<NAME_OF_YOUR_APP>",              // Name of your application
    device: "<NAME_OF_YOUR_DEVICE>",            // The type of device your application is running on
    version: "1",                               // Version of your application
    forwardUrl: "https://localhost:3000",       // Optional - Url to forward back to after signing in.
    platform: "Web",                            // Optional - Platform your application runs on - Defaults to 'Web'
    urlencode: true                             // Optional - If set to true, the output URL is url encoded, otherwise if not specified or 'false', the output URL will return as-is
}

let plexOauth = new PlexOauth(clientInformation);

// Get hosted UI URL and Pin Id
plexOauth.requestHostedLoginURL().then(data => {
    let [hostedUILink, pinId] = data;

    console.log(hostedUILink); // UI URL used to log into Plex

    /*
    * You can now navigate the user's browser to the 'hostedUILink'. This will include the forward URL
    * for your application, so when they have finished signing into Plex, they will be redirected back
    * to the specified URL. From there, you just need to perform a query to check for the auth token.
    * (See Below)
    */

   // Check for the auth token, once returning to the application
   plexOauth.checkForAuthToken(pinId).then(authToken => {
       console.log(authToken); // Returns the auth token if set, otherwise returns null

       // An auth token will only be null if the user never signs into the hosted UI, or you stop checking for a new one before they can log in
   }).catch(err => {
       throw err;
   });

}).catch(err => {
    throw err;
});