README
QuickAuth Client
A simple node module for using Alles' QuickAuth system. It has two functions - generating a url to redirect the user to, and getting the user id from a token. To generate the url, use quickauth.url(applicationId, redirectUrl, data), and the user will be redirected back with a token query parameter. The data parameter is optional and used for passing parameters. It must be a string. If used, the callback will have a data query parameter along with the token one. You can then obtain the user id from that token using the asynchronous quickauth(applicationId, token) function.
NEW! Application Registration
As of October 16th 2020, an application must be registered and the user will see a page where they can confirm the authentication flow (unless internally disabled). See the QuickAuth repository for more information about registering an application.
Example
First, the user must be sent to quickauth to get a token, then redirected back to your site, eg:
app.get("/auth", (req, res) => {
res.redirect(quickauth.url("515dbcfc-d3ee-4344-a27f-53c1f8439022", "https://example.com/auth/cb", "promo-123"));
});
Once the user has been redirected back, get the user id from the token:
app.get("/auth/cb", (req, res) => {
console.log(`Promotion: ${req.query.data}`);
quickauth("515dbcfc-d3ee-4344-a27f-53c1f8439022", req.query.token).then(id => {
res.send(`User: ${id}`);
}).catch(() => {
res.status(400).send("The token didn't work :/");
});
});