@shoppredigital/omnilogin
v0.0.5
Published
OmniLogin Client SDK for Javascript/Nodejs
Downloads
4
Readme
OmniLogin Node.js SDK
Getting Started
You need to install OmniLogin and set API credentials before you get started
If you not installed yet, you can install using below options
Installation
npm i @shoppredigital/omnilogin -S
Usage
/**
* Main application file
*/
if (!process.env.OMNILOGIN_SECRET) {
process.env.OMNILOGIN_SECRET = 'your-secret';
}
if (!process.env.OMNILOGIN_URL) {
process.env.OMNILOGIN_URL = 'https://login.yourdomain.com';
}
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');
const omnilogin = require('@shoppredigital/omnilogin');
const app = express();
const server = http.createServer(app);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.get('/secured', omnilogin.authenticate, (req, res) => {
return res.json(req.user);
// - req.user show user details, only if user session is active and url is secured by OmniLogin
});
server.listen(8000, '0.0.0.0', (err) => {
if (err) return console.log('Error while starting nodejs', err);
return console.log('Server started');
});