Library options
Latest library version: 3.2.2
The library can be customized to match your needs, here are all options you can use:
1
window.oneaccount.init("your external id" /* required */, {
2
iOSRedirectURL: "redirect on iOS here after authentication", // required
3
callbackURL: "callback URL for your external app",
4
updateInterval: <time in ms>, // default: 3 * 60 * 1000
5
color: "css color", // default: "#3C444F"
6
instructions: true, // default: true
7
// show instructions
8
// NOTE: instructions could an object if you want to internationalize the library
9
// the text is in russian and only used for demonstration purposes
10
// instructions: {
11
// title: "Скачайте One account приложение и просканируйте QR code",
12
// subtitle: "или нажмите на QR code если One account приложение установлено на данном устройстве"
13
// },
14
icons: true, // default: true
15
// show icons
16
modal: true, // default: true
17
// use modal mode
18
// if modal: false target must be specified
19
target: <DOM element>, // default: false
20
// embed the library into this element
21
level: <one of "L", "M", "Q", "H">, // default: "L"
22
// defines the level for QR code
23
enableWithCredentials: false, // default: false
24
// set this to true if you set auth cookies (sets withCredentials on the request
25
// so the auth cookies can be set in the browser
26
});
Copied!
There are a few events you can subscribe to:
oneaccount-loaded - this event is triggered right after the library is loaded
1
document.addEventListener("oneaccount-loaded", () => {
2
// this function is mainly used to initialize the library
3
});
Copied!
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)
1
document.addEventListener("oneaccount-authenticated", (event) => {
2
// data contains any data you have returned from the backend
3
var data = event.detail;
4
// your business logic here
5
});
Copied!
Last modified 2mo ago
Copy link