Skip to content

Setting Up in Server Mode

Maclyn Brandwein edited this page Apr 21, 2016 · 2 revisions

Note this must be done before the server starts listening. You'll need to create an Express app before doing this. Then, do as follows:

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
});

Afterwards, you can setup a route on your Express app to perform the Pavlok authorization. You'll be redirected to successUrl or errorUrl depending on whether the authorization works. This routing is done as follows:

app.get("/auth", function(req, res){
	pavlok.auth(req, res);
});

You're now ready to send stimuli!

Clone this wiki locally