This package has been deprecated

Author message:

Please use Pavlok module instead

pavlok-beta-api-login

2.0.5 • Public • Published

Pavlok API Module

Purpose

The Pavlok module makes it easy to play with your Pavlok through a Node enabled environment (local mode), and also to run simple Express web apps integrated with Pavlok (server mode).

Using this module requires permission to listen on one of your computer's ports (local mode only) or permission to run a server (server mode only) and a client ID/client secret. See here and login with your Pavlok account to get one. You'll need to choose a callback URL of "http://localhost:3000/auth/pavlok/result" for local mode (or some variation of that with a different port), though custom callback URLs are supported (and required!) for server mode.

Setup

npm install --save pavlok-beta-api-login
var pavlok = require('pavlok-beta-api-login');

Authentication (Server)

//This must be done before the server starts listening!
pavlok.init("clientId", 
            "clientSecret", {
    "verbose": true,
    "app" : app, //Express server
    "message": "Hello from the server example!", //Default message for all stimuli
    "callbackUrl": "http://www.myserver.com/pavlok/result", 
    "callbackUrlPath": "/pavlok/result",
    "successUrl": "/success", //Where to redirect when the token has been saved to session
    "errorUrl": "/error" //Where to redirect when the token couldn't be gotten/saved
});
app.get("/auth", function(req, res){ //
    pavlok.auth(req, res);
});

Authentication (Local)

pavlok.init("clientId", 
            "clientSecret", {
    "port": 3000 //Port to run the auth token accepting server on
});
pavlok.login(function(result, code){
    if(result){
        console.log("Code is " + code);
    }
});

Further Reading

See the full documentation and examples for full documentation and a walkthrough.

Notes for Users Coming from Versions < 2

Though simliar, older versions of the module use slightly different syntax. All the stimuli messages (zap, beep, etc.) now take their arguments in a single object with named parameters instead of the old ordered argument list. Versions before 2 also didn't support server mode of the pattern option.

License

Licensed under the ISC license.

Readme

Keywords

Package Sidebar

Install

npm i pavlok-beta-api-login

Weekly Downloads

8

Version

2.0.5

License

ISC

Unpacked Size

25.8 kB

Total Files

7

Last publish

Collaborators

  • maneesh