| summary | read_when | |||
|---|---|---|---|---|
Factory (Droid) provider data sources: browser cookies, WorkOS tokens, and Factory APIs. |
|
Factory (displayed as "Droid") is web-based. We authenticate via cookies or WorkOS tokens and call Factory APIs.
Fetch attempts run in this exact order:
- Cached cookie header (Keychain cache
com.steipete.codexbar.cache, accountcookie.factory). - Stored session (
~/Library/Application Support/CodexBar/factory-session.json). - Stored bearer token (same session file).
- Stored WorkOS refresh token (same session file).
- Local storage WorkOS tokens (Safari + Chrome/Chromium/Arc leveldb).
- Browser cookies (Safari only) for Factory domains.
- WorkOS cookies (Safari) to mint tokens.
- Browser cookies (Chrome, Firefox) for Factory domains.
- WorkOS cookies (Chrome, Firefox) to mint tokens.
If a step succeeds, we cache cookies/tokens back into the session store.
Manual option:
- Preferences → Providers → Droid → Cookie source → Manual.
- Paste the
Cookie:header from app.factory.ai.
- Cookie domains:
factory.ai,app.factory.ai,auth.factory.ai. - Cookie names considered a session:
wos-session__Secure-next-auth.session-tokennext-auth.session-token__Secure-authjs.session-token__Host-authjs.csrf-tokenauthjs.session-tokensessionaccess-token
- Stale-token retry filters:
access-token,__recent_auth.
- Candidates are tried in order (deduped):
https://auth.factory.aihttps://api.factory.aihttps://app.factory.aibaseURL(defaulthttps://app.factory.ai)
- Cookie domains influence candidate ordering (auth domain first if present).
All requests set:
Accept: application/jsonContent-Type: application/jsonOrigin: https://app.factory.aiReferer: https://app.factory.ai/x-factory-client: web-appAuthorization: Bearer <token>when a bearer token is available.Cookie: <session cookies>when cookies are available.
Endpoints:
GET <baseURL>/api/app/auth/me- Returns org + subscription metadata + feature flags.
POST <baseURL>/api/organization/subscription/usage- Body:
{ "useCache": true, "userId": "<id?>" } - Returns Standard + Premium token usage and billing window.
- Body:
- Endpoint:
POST https://api.workos.com/user_management/authenticate
- Body:
client_id: one ofclient_01HXRMBQ9BJ3E7QSTQ9X2PHVB7client_01HNM792M5G5G1A2THWPXKFMXB
grant_type:refresh_tokenrefresh_token: from local storage or session store- Optional:
organization_id - When using cookies:
useCookie: true+Cookie: <workos.com cookies>
- Safari:
- Root:
~/Library/Containers/com.apple.Safari/Data/Library/WebKit/WebsiteData/Default - Finds
originfiles containingapp.factory.aiorauth.factory.ai, then readsLocalStorage/localstorage.sqlite3.
- Root:
- Chrome/Chromium/Arc/Helium:
- Roots under
~/Library/Application Support/<Browser>/User Data/<Profile>/Local Storage/leveldb. - Helium uses
~/Library/Application Support/net.imput.helium/<Profile>/Local Storage/leveldb(noUser Data). - Scans LevelDB files for
workos:refresh-tokenandworkos:access-token.
- Roots under
- Parsed tokens:
workos:refresh-token(required)workos:access-token(optional)- Organization ID parsed from JWT when available.
- File:
~/Library/Application Support/CodexBar/factory-session.json - Stores cookies + bearer token + WorkOS refresh token.
- Primary: Standard usage ratio.
- Secondary: Premium usage ratio.
- Reset: billing period end date.
- Plan/tier + org name from auth response.
Sources/CodexBarCore/Providers/Factory/FactoryStatusProbe.swiftSources/CodexBarCore/Providers/Factory/FactoryLocalStorageImporter.swift