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

AngularJS Examples

JavaScript SDK

Angular Integration

Step 1: Add SDK in angular.json

Include the Authyo SDK globally:


// angular.json
"scripts": [
  "https://app.authyo.io/js/v1/auth-sdk.js"
]

Step 2: Add the Container in Component

Use a simple div placeholder in your HTML:

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

Step 3: Initialize Authyo in Component

Use lifecycle hook to initialize with your app key:

   
declare global {
  interface Window { authyoResponse: any; }
}

export class AppComponent implements OnInit {
ngOnInit(): void {
const script = document.createElement('script');
script.src = "https://app.authyo.io/js/v1/auth-sdk.js";
script.setAttribute("data-appkey", "YOUR_APP_KEY");
document.body.appendChild(script);

window.authyoResponse = (response: any) => {
if (response.success) {
console.log("āœ… Success", response.data);
} else {
console.error("āŒ Error", response.message);
}
};
}

}

'

Example: Full Angular HTML + Component


// app.component.html
<div id="authyo-sdk"></div>

// app.component.ts
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
ngOnInit(): void {
const script = document.createElement('script');
script.src = "https://app.authyo.io/js/v1/auth-sdk.js";
script.setAttribute("data-appkey", "123456-app-key-xyz");
document.body.appendChild(script);

window.authyoResponse = (response: any) => {
if (response.success) {
console.log("User verified:", response.data);
} else {
console.error("Login failed:", response.message);
}
};
}
}

Customization (Auto-loaded)

Custom settings are fetched via App Key from dashboard:

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

Supported Login Methods

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

Response Structure

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

Troubleshooting

ProblemFix
Widget not loadingEnsure #authyo-sdk div exists in HTML
No response callbackDeclare window.authyoResponse in TS
Blank screenUse a valid App Key
Wrong stylesCheck customization in dashboard
Modified atĀ 2025-08-23 07:35:46
Previous
PHP
Next
TypeScript Examples
Built with