Place a container element in your HTML to hold the Authyo widget.
<div id="authyo-sdk"></div>
Include the hosted Authyo SDK and pass your App Key using data-appkey
:
<script src="https://app.authyo.io/js/v1/auth-sdk.js" data-appkey="<?php echo $APP_KEY; ?>"></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-sdk"></div>
<script src="https://app.authyo.io/js/v1/auth-sdk.js" data-appkey="<?php echo $APP_KEY; ?>"></script>
<script>
window.authyoResponse = function(response) {
if (response.success) {
console.log("User verified:", response.data);
} else {
console.log("Login failed:", response.message);
}
};
</script>
Your App Key pulls styling options automatically:
{
"success": true,
"message": "OTP verified successfully",
"data": { "abc@xyz.com"}
}
Problem | Fix |
---|---|
Widget not loading | Ensure #authyo-sdk div exists before the script |
Blank screen | Ensure valid data-appkey is used |
No response callback | Implement window.authyoResponse |
Styling off | Check App Key design settings in dashboard |