Place a container element in your HTML to hold the Authyo widget.
<div id="authyo-2fasdk"></div>
Include the hosted Authyo SDK and pass your App Key using data-appkey
:
<script src="https://app.authyo.io/js/v1/auth-2fasdk.js" data-appkey="YOUR_APP_KEY" data-emailid="abc@xyz.com" ></script>
Handle success or failure using window.authyoResponse
:
<script>
window.authyoResponse = function(response) {
if (response.success) {
alert('Success: ' + response.message);
} else {
alert('Error: ' + response.message);
}
};
</script>
<div id="authyo-2fasdk"></div>
<script src="https://app.authyo.io/js/v1/auth-2fasdk.js" data-appkey="123456-app-key-xyz" data-emailid="abc@xyz.com" ></script>
<script>
window.authyoResponse = function(response) {
if (response.success) {
console.log("User verified:", response.data);
} else {
console.log("Login failed:", response.message);
}
};
</script>
{ "domainUrl": "<origin>", "appKey": "<appkey>", "identity": "<email>" }
{ "success": true, "IsTOtpVerified": false, "message": "ok" }
{ "domainUrl": "<origin>", "appKey": "<appkey>", "identity": "<email>" }
{ "success": true, "message": "qrcode generated successfully", "QRCoder": "data:image/png;base64,....", "maskId": "optional" }
{ "appKey": "<appkey>", "domainUrl": "<ui-origin>", "identity": "<email>", "maskId": "optional", "otp": "123456" }
{ "success": true, "message": "verified" }
{ "domainUrl": "<origin>", "appKey": "<appkey>", "identity": "<email>" }
{ "success": true, "message": "2FA disabled" }
Problem | Fix |
---|---|
Widget not loading | Ensure #authyo-2fasdk div exists before the script |
Blank screen | Ensure valid data-appkey and data-emailid is used |
No response callback | Implement window.authyoResponse |
Styling off | Check App Key design settings in dashboard |