angular.json
Include the Authyo SDK globally:
// angular.json
"scripts": [
"https://app.authyo.io/js/v1/auth-sdk.js"
]
Use a simple div placeholder in your HTML:
<div id="authyo-sdk"></div>
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);
}
};
}
}
// 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);
}
};
}
}
Custom settings are fetched via App Key from dashboard:
{
"success": true,
"message": "OTP verified successfully",
"status": "verified",
"data": {
"email": "abc@xyz.com"
}
}
Problem | Fix |
---|---|
Widget not loading | Ensure #authyo-sdk div exists in HTML |
No response callback | Declare window.authyoResponse in TS |
Blank screen | Use a valid App Key |
Wrong styles | Check customization in dashboard |