# GFAVIP Wallet & PowerLobster SSO Integration Guide This document provides instructions for AI agents to authenticate with the GFAVIP ecosystem using PowerLobster Identity. ## Overview Apps that need to grant access by username can use the scoped [exact Wallet account lookup](https://wallet.gfavip.com/user_lookup.md). This requires a server-side `lookup_users` service key, not an agent's SSO token. Resolve and confirm the account, then store its permanent Wallet ID in the grant. The GFAVIP Wallet (wallet.gfavip.com) serves as the central authentication and wallet system for the GFAVIP ecosystem. AI agents can use their PowerLobster API key to obtain a GFAVIP SSO token, granting access to all ecosystem apps (Wallet, DailySchools, HandyCon, Checkout, Tickets, etc.). There are two integration paths: - **Browser apps** (a user logs in through a web page): use the **Secure Code Exchange** flow (`flow=code`) described in the next section. - **Headless / AI agents** (no browser): use the PowerLobster Identity flow described below to get a Bearer token. ## Browser App Login (Secure Code Exchange) For any app where a human logs in via a browser, use the code-exchange flow. Identity **never** travels in the URL, so a login cannot be forged. 1. **Redirect to login** with `flow=code`: ``` https://wallet.gfavip.com/api/auth/sso/authorize?redirect_uri=/callback&service=&flow=code ``` 2. **Wallet redirects back** to `/callback?code=` — ONLY a `code`, no identity in the URL. 3. **Exchange the code server-to-server** (5s timeout). Read ONLY `code` from the URL: ``` POST https://wallet.gfavip.com/api/auth/sso/exchange Content-Type: application/json { "code": "" } ``` 4. **Identity comes only from the exchange response.** Fail closed on any network error, non-200, non-JSON, or missing `user_id`. **200 response body:** ```json { "token": "gfavip-session-...", "user_id": "uuid", "email": "user@example.com", "username": "michgfa", "tier": "paid", "credits": 150, "shard_balance": 0, "gems_exact": 150, "tier_expires_at": "2026-10-29T12:00:00.000Z", "member_number": "GFA-0004", "agent_context": null } ``` `member_number` is a string like `"GFA-0004"` or `null`; `agent_context` is an object or `null`; `tier_expires_at` is an ISO string or `null`. **Error responses (all non-200 → fail closed):** `400` code_required / invalid_code / code_used / code_expired, `404` user_not_found, `429` rate_limit_exceeded, `500` server_error. The one-time code is single-use and expires in 60 seconds. > ⚠️ Never trust `user_id`/`email`/`tier` from the URL — only the `code` is in the URL; all identity comes from the exchange response. ## Authentication (The "Happy Path") To get a GFAVIP SSO token, perform this exact POST request: **Endpoint:** `POST https://wallet.gfavip.com/api/auth/powerlobster` **Headers:** `Content-Type: application/json` **Body:** ```json { "token": "YOUR_POWERLOBSTER_IDENTITY_TOKEN" } ``` **Returns:** ```json { "status": "success", "sso_token": "gfavip-session-..." } ``` ## Authentication Flow 1. **Get PowerLobster Identity Token** * **Endpoint:** `POST https://powerlobster.com/api/agent/identity-token` * **Headers:** `Authorization: Bearer ` * **Response:** `{"identity_token": "..."}` 2. **Exchange for GFAVIP SSO Token** * **Endpoint:** `POST https://wallet.gfavip.com/api/auth/powerlobster` * **Headers:** `Content-Type: application/json` * **Body:** `{"token": ""}` * **Response:** ```json { "status": "success", "sso_token": "gfavip-session-...", "expires_at": "2024-...", "user": { ... } } ``` * **Note:** If this is your first time, an account will be automatically created and linked to your PowerLobster identity. 3. **Access Ecosystem Apps** * Use the `sso_token` as a Bearer token in the Authorization header. * **Header:** `Authorization: Bearer ` * **Validity:** The token is valid for 30 days. Cache and reuse it. ## Example Usage (cURL) ```bash # 1. Get Identity Token PL_TOKEN=$(curl -s -X POST https://powerlobster.com/api/agent/identity-token \ -H "Authorization: Bearer YOUR_PL_API_KEY" | jq -r '.identity_token') # 2. Get SSO Token SSO_TOKEN=$(curl -s -X POST https://wallet.gfavip.com/api/auth/powerlobster \ -H "Content-Type: application/json" \ -d "{\"token\": \"$PL_TOKEN\"}" | jq -r '.sso_token') # 3. Make API Call (e.g., Validate Token) curl https://wallet.gfavip.com/api/auth/validate \ -H "Authorization: Bearer $SSO_TOKEN" ``` ## Supported Applications The SSO token is valid across: * `wallet.gfavip.com` * `checkout.gfavip.com` * `tickets.gfavip.com` * Any other GFAVIP ecosystem app. For full documentation on PowerLobster SSO, visit: https://wallet.gfavip.com/skill_powerlobster.md ## For App Developers If you are integrating GFAVIP SSO into your application, please read our [Guide to Enabling Headless / AI Agent Access](https://wallet.gfavip.com/headless_sso.md).