Skip to content

Setup with Init

Maclyn Brandwein edited this page Apr 21, 2016 · 1 revision

The init function's first two parameters are your client ID and client secret. Its third parameter is an option bundle. The various fields in the bundle are documented here:

Shared between local/server modes

apiUrl (string, optional) - The Pavlok API to query (default is fine).

verbose (boolean, optional) - Whether to enable verbose logging.

message (string, optional) - The default message to send with stimuli.

app (object, optional) - The Express app to setup to be a server. If present, the module will setup in server mode; if not, the module will setup in local mode.

Server Mode

callbackUrl (string) - The callback URL associated with your CID/CSecret.

callbackUrlStub (string) - The path of your callback URL relative to your root (e.g. "/pavlok/postauth").

successPath (string) - The relative path to redirect to after a successful authorization.

failurePath (string) - The relative path to redirect to after a failed authorization.

handleSessions (boolean, optional) - Whether the module should setup a request.session(...) for you. Defaults to true. If you do this yourself, you must make sure request.session exists for this module to use.

sessionSecret (string, optional) - The secret to secure a user's session with.

Local Mode

In client mode, the callback URL you must register with your client ID/client secret is "http://localhost:PORT_YOU_CHOOSE/auth/pavlok/result".

save (boolean, optional) - Whether to save access tokens between sessions.

tokenFile (string, optional) - The name of the token file.

port (number, optional) - The port to run the client server for fetching auth tokens on. Defaults to 3000; running under 1024 might need root privileges on some systems.

Clone this wiki locally