# pavlok-beta-api-login

> A module to connect with Pavlok's API easily and quickly.

Latest version **2.0.5** (published 2020-07-29) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install pavlok-beta-api-login
pnpm add pavlok-beta-api-login
yarn add pavlok-beta-api-login
bun add pavlok-beta-api-login
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.5 |
| Published | 2020-07-29 |
| First published | 2015-08-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 25.2 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 34 |
| Author | Behavior Technology Group, Inc. |
| Maintainers | maneesh |
| Keywords | pavlok, api, login, shock |

## Links

- npm: https://www.npmjs.com/package/pavlok-beta-api-login
- Repository: https://github.com/Behavioral-Technology-Group/Pavlok_Node_Module
- Homepage: https://github.com/Behavioral-Technology-Group/Pavlok_Node_Module#readme
- Issues: https://github.com/Behavioral-Technology-Group/Pavlok_Node_Module/issues
- npm.io page: https://npm.io/package/pavlok-beta-api-login

## Dependencies (6)

- [open](https://npm.io/package/open.md) 0.0.5
- [express](https://npm.io/package/express.md) ^4.13.3
- [request](https://npm.io/package/request.md) ^2.67.0
- [body-parser](https://npm.io/package/body-parser.md) ^1.14.1
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.4.0
- [cookie-session](https://npm.io/package/cookie-session.md) ^2.0.0-alpha.1

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 2.0.5 (latest) — 2020-07-29
- 2.0.4 — 2016-05-26
- 2.0.3 — 2016-05-20
- 2.0.2 — 2016-05-20
- 2.0.1 — 2016-05-19
- 2.0.0 — 2016-04-21
- 1.3.1 — 2016-03-15
- 1.3.0 — 2016-03-15
- 1.1.5 — 2016-02-03
- 1.1.4 — 2016-01-19
- 1.1.3 — 2016-01-13
- 1.1.2 — 2016-01-01
- 1.1.1 — 2015-12-15
- 1.1.0 — 2015-12-15
- 1.0.1 — 2015-08-20
- … 2 more at https://npm.io/package/pavlok-beta-api-login/versions

## README

# 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](http://pavlok-mvp.herokuapp.com/oauth/applications) 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](https://github.com/Behavioral-Technology-Group/Pavlok_Node_Module/wiki) and [examples](https://github.com/Behavioral-Technology-Group/Pavlok-Node-Samples) 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.

---
_Source: https://npm.io/package/pavlok-beta-api-login · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
