Giter VIP home page Giter VIP logo

node-plex-api-pinauth's Introduction

node-plex-api-pinauth

An authentication module for node-plex-api that handles the API requests necessary for getting an auth token using a PIN.

No Longer Maintained

I am no longer maintaining this repo. However, Zefau has been doing some recent development over on this fork, so head on over there: https://github.com/Zefau/node-plex-api-pinauth

Current State

It's usable, but it's ugly. One of the public methods returns a promise while the other uses a callback. That's dumb. There are other dumb things too that need to be cleaned up.

But it works!

Usage

var plexApi = require('plex-api');
var plexPinAuth = require('plex-api-pinauth')();

var plexClient = new PlexAPI({
    hostname: '192.168.0.1',
    authenticator: plexPinAuth
});

// Use getNewPin to get a new PIN object with these parameters:
// code: The 4-digit PIN that the user should enter on https://plex.tv/pin to grant authorization
// id: the ID of the PIN, which you'll need to use when checking if we have authorization yet
plexPinAuth.getNewPin().then(function(pinObj){
    console.log(pinObj)
    // {code: 'ABCD', id: '12345678'}
});

// Use checkPinForAuth to check to see if the user has entered the PIN on the website yet.
// returns a string representing 3 possible results:
// "authorized": The user has granted authorization and we now have the token. You can use plexClient now.
// "waiting": The user has not yet granted authorization.
// "invalid": The PIN is no longer (or never was) valid. PINs only remain valid for about 10 minutes.
plexPinAuth.checkPinForAuth(pinObj, function callback(err, status) {
    if(err) {
        // uh oh
    } else {
        console.log(status);
        // "authorized"
    }
});

node-plex-api-pinauth's People

Contributors

overloadut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-plex-api-pinauth's Issues

More detailed example

Do you have a more detailed example? I am stuck when .authenticate() runs. It doesn't seem to be logging me in. I keep getting User has not authenticated yet. Just wondering if you have a more detailed example.

plexPinAuth.checkPinForAuth() is returning me authorized properly as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.