Wind Connect — OAuth
Let users link their portable Wind wallet to your app via a standard OAuth code exchange.
Step 1 — Register a redirect URI
In your app's General tab, register the callback URL.
text
https://yourapp.com/callback
Step 2 — Redirect to Wind Connect
typescript
const url = new URL('https://user.usewind.app/connect')
url.searchParams.set('app_id', YOUR_APP_ID)
url.searchParams.set('redirect_uri', 'https://yourapp.com/callback')
url.searchParams.set('state', crypto.randomUUID())
window.location.href = url.toString() Step 3 — Exchange the code (server-side)
typescript
const response = await fetch('https://wind-production-3225.up.railway.app/user/connect/exchange', {
method: 'POST',
headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({ code: req.query.code, redirectUri: 'https://yourapp.com/callback' }),
})
const { windUserId } = await response.json()
Codes expire after 10 minutes and are single-use. Always verify the
state parameter to prevent CSRF.
Wind Connect — Link Mode
Simpler than OAuth. Wind returns the wallet ID directly in the URL.
Step 1 — Redirect
typescript
const url = new URL('https://user.usewind.app/connect')
url.searchParams.set('mode', 'link')
url.searchParams.set('app_id', 'your-app-id')
url.searchParams.set('external_user_id', currentUser.id)
url.searchParams.set('return_url', 'https://yourapp.com/account')
url.searchParams.set('app_name', 'Your App')
window.location.href = url.toString() Step 2 — Handle the return URL
text
# Success ?connected=true&wind_user_id=<uuid>&wind_email=user@example.com&balance_cents=500 # User denied ?error=denied
No redirect URI registration required. Any app can start using Wind billing without prior setup.
Wind Connect — Popup Mode
Opens Wind Connect in a popup and communicates the result back via postMessage.
Step 1 — Open the popup
typescript
const url = new URL('https://user.usewind.app/connect')
url.searchParams.set('mode', 'popup')
url.searchParams.set('allowed_origin', 'https://yourapp.com')
url.searchParams.set('app_id', 'your-app-id')
url.searchParams.set('external_user_id', currentUser.id)
const popup = window.open(url.toString(), 'wind-connect', 'width=480,height=640') Step 2 — Listen for the result
typescript
window.addEventListener('message', (event) => {
if (event.origin !== 'https://user.usewind.app') return
if (event.data.type === 'wind_connected') {
const { wind_user_id, wind_email } = event.data
}
})