Authyo Docs
  1. Web SDKs
Authyo Docs
  • 🐶 Walk through Authyo
  • Error Codes
  • About Pricing
  • APIs
    • Send OTP
      GET
    • Send OTP
      POST
    • Verify OTP
      GET
    • Verify Token
      POST
  • Web SDKs
    • JavaScript
    • PHP
    • AngularJS Examples
    • TypeScript Examples
    • React JS
    • Vue JS Examples
  • Native/Mobile SDKs
    • Flutter
  1. Web SDKs

PHP

JavaScript SDK

PHP Integration

Step 1: Add the Container

Place a container element in your HTML to hold the Authyo widget.

<div id="authyo-sdk"></div>

Step 2: Include the SDK Script

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>

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>

Example: Complete Integration

<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>

Customization (Auto-loaded from Dashboard)

Your App Key pulls styling options automatically:

  • Logo, text, and titles
  • Button shape, color, and font
  • Input styles and behavior
  • Social button layout (top/bottom)
  • Show/hide branding
  • Links to Terms & Privacy

Supported Login Methods

  • āœ… Email OTP
  • āœ… SMS / WhatsApp / Voicecall
  • āœ… QR Code Login
  • āœ… Google / Microsoft / LinkedIn / GitHub

Response Structure

{
  "success": true,
  "message": "OTP verified successfully",
  "data": { "abc@xyz.com"}
}

Troubleshooting

ProblemFix
Widget not loadingEnsure #authyo-sdk div exists before the script
Blank screenEnsure valid data-appkey is used
No response callbackImplement window.authyoResponse
Styling offCheck App Key design settings in dashboard
Modified atĀ 2025-08-23 07:35:17
Previous
JavaScript
Next
AngularJS Examples
Built with