Skip to content

Instantly share code, notes, and snippets.

@Chris927
Last active September 10, 2020 04:31
Show Gist options
  • Save Chris927/7d2532360b409e7ec9e5b6fa6414b970 to your computer and use it in GitHub Desktop.
Save Chris927/7d2532360b409e7ec9e5b6fa6414b970 to your computer and use it in GitHub Desktop.
otplib, generate uri (for a qr code), which works for both Google Authenticator and Microsoft Authenticator
const { authenticator } = require('otplib')
const crypto = require('crypto')
authenticator.options = { crypto }
const secret = 'LE5ACX24MIUQQUA6' // example secret, replace with whatever the previous script produced
console.log('token', authenticator.generate(secret))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment