Authentication
Embed SDK host integration is based on host-owned identity:
- Host app authenticates user
- Host backend signs TaskOn login payload
- Host frontend calls
embed.login(...)
Login Types
| Auth Type | type value | account |
|---|---|---|
"Email" | User email | |
| EVM Wallet | "WalletAddress" | Wallet address |
Recommended Flow
Use isAuthorized() before login():
const isAuthorized = await embed.isAuthorized("Email", "[email protected]");
if (!isAuthorized) {
const signed = await fetch("/api/taskon/sign", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
type: "Email",
account: "[email protected]",
}),
}).then((res) => res.json());
await embed.login({
type: "Email",
account: "[email protected]",
signature: signed.signature,
timestamp: signed.timestamp,
});
} else {
await embed.login({
type: "Email",
account: "[email protected]",
});
}Wallet Login
Wallet login requires an EIP-1193 provider:
const accounts = await window.ethereum.request({
method: "eth_requestAccounts",
});
const address = accounts[0];
const isAuthorized = await embed.isAuthorized("WalletAddress", address);
if (!isAuthorized) {
const signed = await getWalletSignatureFromServer(address);
await embed.login({
type: "WalletAddress",
account: address,
signature: signed.signature,
timestamp: signed.timestamp,
provider: window.ethereum,
});
} else {
await embed.login({
type: "WalletAddress",
account: address,
provider: window.ethereum,
});
}Logout
// Recommended: keep auth cache for fast re-login
await embed.logout();// Security-sensitive: clear authorization cache
await embed.logout({ clearAuth: true });Handle loginRequired Event
embed.on("loginRequired", () => {
openLoginModal();
});Security Notes
- Never expose TaskOn private key in browser code
- Always generate signatures on server side
- Keep signature
timestampas milliseconds (13 digits)
See Node Utilities for server signing.
Last updated on