Documentation Index
Fetch the complete documentation index at: https://docs.agg.market/llms.txt
Use this file to discover all available pages before exploring further.
Linking builds on the same redirect and callback flows described in
Authentication.
This page is about linking multiple auth providers to one AGG account. If you need to link an
AGG user to your own partner-side user ID, use
Partner External ID Linking.
Users can sign in with a wallet and then link additional providers (Google, Twitter, Apple, email) to the same account.
How It Works
When a user is already authenticated (has a valid JWT), calling authStart() with a different
provider links the new provider to their existing account instead of creating a new one.
Example: Link Google to a Wallet Account
// User is already signed in with SIWE
console.log(client.isAuthenticated); // true
console.log(client.user.id); // "user-123"
// Start Google OAuth — the existing Bearer token tells the API to link accounts
const response = await client.authStart({
provider: "google",
redirectUrl: "https://yourapp.com/auth/callback",
});
// Redirect to Google
if (response.type === "redirect") {
window.location.href = response.url;
}
// On the callback route, finish the redirect flow the same way as the auth recipe.
const code = new URLSearchParams(window.location.search).get("code");
if (code) {
await client.exchangeAuthCode(code);
}
// After the callback completes, the same user now has both linked accounts:
const profile = await client.getCurrentUser();
console.log(profile.accounts);
// [
// { type: "wallet", provider: "wallet", providerAccountId: "0xABC..." },
// { type: "oauth", provider: "google", providerAccountId: "google-user-id" }
// ]
Auto-Linking by Email
If a user signs in with Google (which has a verified email) and another account already exists with that email (e.g., from a magic link sign-in), the accounts are automatically linked. No extra steps needed.
Viewing Linked Accounts
const profile = await client.getCurrentUser();
// GET /users/me
profile.accounts.forEach((account) => {
console.log(`${account.provider}: ${account.providerAccountId}`);
});