This is a demo for OTPless Backend SDK integration in NodeJS.
To integrate the same in TypeScript, check out nodeTS directory.
Pre-requisites: - Node installed
-
Open a new terminal in nodeJS directory.
-
Create a new File
.env
in the root directory and copy and paste contents of.env.example
-
Replace the values of each env variables with your own.
-
Install the required dependencies
npm i
-
Start the server
npm run dev
- Import the Request Collection Config file in your Postman Client APP.
CTRL+O
> Drop the file in the Popup window > Import.- Set the
Current Value
for theVariables
in the root of the collection. - Thats it! Open the requests provide required data in the body or params, and Hit Send Request.
- You will get a successful or error response based on your request.
npm i -S otpless-node-js-auth-sdk
import { UserDetails } from 'otpless-node-js-auth-sdk'
// Send a magic link
await UserDetails.magicLink(mobile, email, redirectURI, channel, clientId, clientSecret)
// Verify code from magic link's approved redirected URI's params
await UserDetails.verifyCode(code, clientId, clientSecret)
// Verify token from OTPless frontend SDK
await UserDetails.verifyToken(token, clientId, clientSecret)
// Send OTP
await UserDetails.sendOTP(phoneNumber, email, channel, hash, orderId, expiry, otpLength, clientId, clientSecret)
// Resend OTP
await UserDetails.resendOTP(orderId, clientId, clientSecret)
// Verify OTP
await UserDetails.verifyOTP(email, phoneNumber, orderId, otp, clientId, clientSecret)
Note: Arguments for all methods are positional and should be in the same order, to skip optional arguments use
null
orundefined
.