Skip to content

ShoppReDigital/node-omnilogin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. DigitalOcean One Click Installation
  2. Installing by your own

Installation

npm i @shoppre/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('@shoppre/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');
});

Releases

No releases published

Packages

No packages published