Add the Authyo container in your Vue template:
<template>
<div id="authyo-sdk"></div>
</template>
Inject the SDK script when the component mounts:
mounted() {
const script = document.createElement("script");
script.src = "https://app.authyo.io/js/v1/auth-sdk.js";
script.setAttribute("data-appkey", "YOUR_APP_KEY");
script.async = true;
document.body.appendChild(script);
}
Use window.authyoResponse
to capture success or failure:
mounted() { // Load SDK const script = document.createElement("script"); script.src = "https://app.authyo.io/js/v1/auth-sdk.js"; script.setAttribute("data-appkey", "YOUR_APP_KEY"); script.async = true; document.body.appendChild(script);
// Capture response
window.authyoResponse = (response) => {
if (response.success) {
console.log("ā Verified:", response.data);
} else {
console.error("ā Error:", response.message);
}
};
}
<template> <div id="authyo-sdk"></div> </template>
<script>
export default {
name: "AuthyoWidget",
mounted() {
const script = document.createElement("script");
script.src = "https://app.authyo.io/js/v1/auth-sdk.js";
script.setAttribute("data-appkey", "123456-app-key-xyz");
script.async = true;
document.body.appendChild(script);
window.authyoResponse = (response) => {
if (response.success) {
console.log("ā User verified:", response.data);
} else {
console.error("ā Login failed:", response.message);
}
};}
};</script>
{
"success": true,
"message": "OTP verified successfully",
"status": "verified",
"data": {
"email": "abc@xyz.com"
}
}
Problem | Fix |
---|---|
Widget not loading | Ensure #authyo-sdk exists before SDK script |
Blank widget | Check that App Key is valid |
No response callback | Define window.authyoResponse |
Wrong styles | Adjust design from dashboard |