Start with the Setup Guide if you still need to wire
createAggClient,
AggProvider, or AggAuthProvider. After sign-in, see Token Refresh
for session renewal, Account Linking for adding additional
providers, and Partner External ID Linking if you need to attach
your own internal user ID to the AGG profile.siwefor Ethereum walletssiwsfor Solana walletsgooglefor Google OAuthtwitterfor X OAuthapplefor Apple Sign Inemailfor magic-link email sign-in
How It Works
All flows start withclient.authStart(...), but they complete in two different ways:
| Flow | Providers | Completion |
|---|---|---|
| Message signing | siwe, siws | Call client.verify({ message, signature }) to receive tokens directly. |
| Redirect / magic link | google, twitter, apple, email | AGG redirects back with ?code=...; call client.exchangeAuthCode(code). |
Bot Protection (challenge_required)
For wallet (siwe, siws) and email (email) providers, AGG enforces an optional Cloudflare
Turnstile challenge when your app crosses its configured user-count threshold. OAuth providers
(google, twitter, apple) bypass this layer — the identity provider is already the human proof.
When the challenge is active, POST /auth/start may return an extra response type:
- Call
client.authStart({ provider: "siwe" }). - If the response type is
challenge_required, render the Cloudflare Turnstile widget using the returnedsiteKey. - On solve, resubmit
client.authStart({ provider: "siwe", turnstileToken: "<cf-token>" }). - The server verifies the token against its linked widget and returns the normal
nonce/magic_linkresponse. - An invalid or reused token returns
403— retry with a fresh Turnstile solve.
SDK: SIWE
SIWE is fully client-side and does not redirect.HttpOnly cookie instead, configure the SDK
client with authDelivery: "cookie-refresh". In that mode, verify() and exchangeAuthCode()
may omit refreshToken from the JSON response. That cookie stays on the AGG API host and is scoped
to /auth routes.
SDK: SIWS
SIWS is also fully client-side and does not redirect.SIWS with Ledger
Ledger is not a separate AGG auth flow. It uses the exact same SIWS contract:client.authStart({ provider: "siws" })client.buildSiwsMessage(...)wallet.signMessage(new TextEncoder().encode(message))bs58.encode(signature)client.verify({ message, signature })
signMessage() but not Phantom’s wallet-specific signIn()
helper. AGG’s SIWS recipe stays Ledger-compatible by building the message in the dapp and signing
the raw UTF-8 bytes directly.
SDK: Google / Twitter / Apple / Email
These four providers all use the same redirect-based flow.- Google
- Twitter
- Apple
- Email
React: recommended @agg-build/auth
Use @agg-build/auth when you want AGG’s connect/sign-in UI without forcing wallet dependencies
into @agg-build/ui. See the Connect Button reference for the
component surface shown below.
Mixed providers
Dedicated callback pages
If your app uses a standalone callback route, useuseAggAuthCallback():
React: useAggAuth
useAggAuth keeps the documented wallet ergonomics for custom UIs.
Ethereum
Solana
Token storage
The SDK automatically persists auth tokens inlocalStorage, keyed by appId, and restores them
when the client is constructed.
Installation matrix
Related
Setup Guide
Wire the base client, providers, and WebSocket connection first.
Token Refresh
Renew access tokens and recover gracefully from session expiry.
Account Linking
Connect additional OAuth providers to the current user profile.
User Notifications
Reuse the same session for authenticated WebSocket events.
Bot Protection
Render and verify Cloudflare Turnstile challenges during sign-in.