Library options

Latest library version: 3.2.2

The library can be customized to match your needs, here are all options you can use:

window.oneaccount.init("your external id" /* required */, {
iOSRedirectURL: "redirect on iOS here after authentication", // required
callbackURL: "callback URL for your external app",
updateInterval: <time in ms>, // default: 3 * 60 * 1000
color: "css color", // default: "#3C444F"
instructions: true, // default: true
// show instructions
// NOTE: instructions could an object if you want to internationalize the library
// the text is in russian and only used for demonstration purposes
// instructions: {
// title: "Скачайте One account приложение и просканируйте QR code",
// subtitle: "или нажмите на QR code если One account приложение установлено на данном устройстве"
// },
icons: true, // default: true
// show icons
modal: true, // default: true
// use modal mode
// if modal: false target must be specified
target: <DOM element>, // default: false
// embed the library into this element
level: <one of "L", "M", "Q", "H">, // default: "L"
// defines the level for QR code
enableWithCredentials: false, // default: false
// set this to true if you set auth cookies (sets withCredentials on the request
// so the auth cookies can be set in the browser
});

There are a few events you can subscribe to:

oneaccount-loaded - this event is triggered right after the library is loaded

document.addEventListener("oneaccount-loaded", () => {
// this function is mainly used to initialize the library
});

oneaccount-authenticated - this event is triggered when you return from the callback function on the backend (make sure you only return code 200 if the user is authenticated)

document.addEventListener("oneaccount-authenticated", (event) => {
// data contains any data you have returned from the backend
var data = event.detail;
// your business logic here
});

Here is the link to the library: https://cdn.jsdelivr.net/npm/[email protected]{verstion}/dist/oneaccount.min.js