generateTOTP
📘 generateTOTP(userID)
API
generateTOTP(userID)
API🧭 Purpose
The generateTOTP
API initiates the generation of a Time-Based One-Time Password (TOTP) for a specified REL-ID user. It enables both online and offline authentication flows by generating a short-lived OTP code securely on the device.
🧩 Parameters
Name | Type | Required | Description |
---|---|---|---|
userID | String | ✅ | REL-ID user identifier for whom TOTP is generated |
🚦 Trigger Flow
- App calls
generateTOTP(userID)
- SDK checks:
- If LDA (biometric/PIN) or password validation is needed
- If required, SDK emits
getTOTPPassword
event - App collects and sends password using
setTOTPPassword(password)
- SDK emits
onTOTPGenerated
with TOTP code and expiry
📤 Related Events
- Triggered only if password-based authentication is required before generating TOTP.
- App must prompt user for password and respond with
setTOTPPassword(password)
.
- Emitted after successful TOTP generation.
- Payload includes the generated code, expiry time, and any error info.
✅ Example Payload
{
"userID": "john.doe",
"TOTP": "758192",
"expiryTimeInSec": 30,
"error": {
"longErrorCode": 0,
"shortErrorCode": 0,
"errorString": "Success"
}
}
🚨 Error Handling
The onTOTPGenerated
event payload includes an error
field which should be checked for:
Error Code | Meaning | Developer Action |
---|---|---|
0 | Success | Proceed with displaying TOTP |
📝 Notes
- TOTP can be generated offline as well, using cached credentials and a device-stored secret.
- Always display a countdown to indicate the time until TOTP expiry.
- If TOTP expires, simply call
generateTOTP(userID)
again to refresh.
💻 Code Snippets
React Native
RdnaClient.generateTOTP(userID, (syncResponse) => {
console.log("TOTP Response:", syncResponse);
});
Flutter
com.uniken.rdnaplugin.RdnaClient.generateTOTP("<userID>");
Cordova
com.uniken.rdnaplugin.RdnaClient.generateTOTP(
successCallback,
errorCallback,
["<userID>"]
);
Native iOS (Objective-C)
RDNAError *error = [rdnaClient generateTOTP:@"<userName>"];
if (error == nil) {
// Handle success
}
Native Android (Java)
RDNA.RDNAError error = RDNA.generateTOTP("john.doe");
if (error == null) {
// Handle success
}
Updated 2 months ago