Place a container element in your HTML to hold the Authyo widget.
<div id="authyo-sdk"></div>
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="YOUR_APP_KEY"></script>
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>
<div id="authyo-sdk"></div>
<script src="https://app.authyo.io/js/v1/auth-sdk.js" data-appkey="123456-app-key-xyz"></script>
<script>
window.authyoResponse = function(response) {
if (response.success) {
console.log("User verified:", response.data);
} else {
console.log("Login failed:", response.message);
}
};
</script>
Your App Key pulls styling options automatically:
{
"success": true,
"message": "OTP verified successfully",
"data": { "abc@xyz.com"}
}
| Problem | Fix |
|---|---|
| Widget not loading | Ensure #authyo-sdk div exists before the script |
| Blank screen | Ensure valid data-appkey is used |
| No response callback | Implement window.authyoResponse |
| Styling off | Check App Key design settings in dashboard |
WARNING: You MUST securely validate the Verification Token (JWT) on your own backend!
When a user successfully logs in via ANY method (OTP, Passkey, Google One Tap, Social Media), the Authyo SDK returns a token to the client browser.
Client-side confirmation (success: true) is NOT enough to log a user into your application securely, as client-side JavaScript can be manipulated by malicious users.
HOW TO USE IT SECURELY:
window.authyoResponse.VerifyToken endpoint).Handles the credential response returned silently by the Google One Tap iframe/overlay.
{
"success": true,
"status": "success",
"message": "verified successfully",
"data": {
"tokenType": "Bearer",
"token": "eyJhbGciOiJIUz...", <-- THIS MUST BE VERIFIED BY YOUR BACKEND
"expiresIn": 1799,
"user": {
"identity": "user@gmail.com",
"userId": "AY-..."
}
}
}
Performs cryptographic validation of the WebAuthn user assertion.
{
"id": "credential_id_string",
"rawId": "base64url_encoded_string",
"type": "public-key",
"extensions": {},
"response": {
"authenticatorData": "base64url_encoded_string",
"clientDataJSON": "base64url_encoded_string",
"signature": "base64url_encoded_string"
},
"userName": "user@example.com",
"deviceId": "optional_device_identifier"
}
{
"Status": "ok",
"ErrorMessage": "",
"Message": "passkey authentication successful",
"Data": {
"tokenType": "Bearer",
"token": "eyJhbGciOiJIUz...", <-- THIS MUST BE VERIFIED BY YOUR BACKEND
"expiresIn": 1799,
"user": {
"identity": "user@example.com",
"userId": "AY-..."
}
}
}
(Google, Microsoft, GitHub, LinkedIn standard OAuth redirects)
Popup Authentication & postMessage Callback**
Once the user successfully authenticates in the popup, the Authyo /callback endpoint pushes a MessageEvent back to the parent window containing the complete JSON payload. The SDK (auth-sdk.js) intercepts this and feeds it to window.authyoResponse.
{
"success": true,
"message": "verified successfully",
"token": "eyJhbGciOiJIUz...", <-- THIS MUST BE VERIFIED BY YOUR BACKEND
"email": "user@example.com",
"data": {
"tokenType": "Bearer",
"token": "eyJhbGciOiJIUz...",
"expiresIn": 1799,
"identity": "user@example.com",
"email": "user@example.com",
"user": {
"identity": "user@example.com",
"userId": "AY-..."
}
}
}
(Note: As securely implemented, the payload positions the token and email redundantly to ensure clients extract the Verification Token cleanly.)