Authyo Docs
  1. 2FA SDK
Authyo Docs
  • 🐶 Walk through Authyo
  • Error Codes
  • About Pricing
  • APIs
    • Send OTP
      GET
    • Send OTP
      POST
    • Verify OTP
      GET
    • Verify Token
      POST
    • Revoke User Session
      POST
  • Web SDKs
    • JavaScript
    • PHP
    • AngularJS Examples
    • TypeScript Examples
    • React JS
    • Vue JS Examples
  • 2FA SDK
    • JavaScript
    • AngularJS Examples
    • PHP
    • React JS
    • TypeScript Examples
    • Vue JS Examples
  • Native/Mobile SDKs
    • Flutter
  • Integration
    • Google Sheet
    • Firebase
  • Session Management
    • Introductions
    • JWT Token
  1. 2FA SDK

Vue JS Examples

JavaScript SDK

Vue.js Integration

Step 1: Add the Container

Add the Authyo container in your Vue template:

<template>
  <div id="authyo-2fasdk"></div>
</template>

Step 2: Load the SDK Script Dynamically

Inject the SDK script when the component mounts:

mounted() {
  const script = document.createElement("script");
  script.src = "https://app.authyo.io/js/v1/auth-2fasdk.js";
  script.setAttribute("data-appkey", "YOUR_APP_KEY");
  script.setAttribute("data-appkey", "abc@xyz.com");
  script.async = true;
  document.body.appendChild(script);
}

Step 3: Optional – Capture the Response

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>

Two Factor Authenticate – Requests & Responses

1) AuthState
Response
{
  "success": true,
  "IsTOtpVerified": false,
  "message": "ok"
}
    
2) Enable 2FA
Response
{
  "success": true,
  "message": "qrcode generated successfully",
  "QRCoder": "data:image/png;base64,....",
  "maskId": "optional"
}
    
3) Verify Otp
Response
{ "success": true, "message": "verified" }
    
4) Disable 2FA
Response
{ "success": true, "message": "2FA disabled" }
    

Troubleshooting

ProblemFix
Widget not loadingEnsure #authyo-2fasdk div exists before the script
Blank screenEnsure valid data-appkey and data-emailid is used
No response callbackImplement window.authyoResponse
Styling offCheck App Key design settings in dashboard
Modified at 2025-10-06 13:16:05
Previous
TypeScript Examples
Next
Flutter
Built with