v3: GitHub OAuth authorer (primary $1 door), sanitized gh_session, README rewrite
This commit is contained in:
@@ -2,91 +2,98 @@
|
||||
|
||||
Mass auto-registration toolkit for **[treg.to](https://treg.to/)** — the "OpenRouter for agent tools" (3955 endpoints, 111 providers, one API key).
|
||||
|
||||
Each fresh account gets a **$1.00 signup grant** (~1600–2000 tool calls: X/Twitter posts at $0.0005, TikTok profiles at $0.001, web search free). Zero captcha — pure email OTP flow.
|
||||
Each fresh account gets a **$1.00 signup grant** (~1600–2000 tool calls: X/Twitter posts at $0.0005, TikTok profiles at $0.001, web search free).
|
||||
|
||||
**v3: the primary door is GitHub OAuth** (`gh_oauth_reg.py`). The old email+OTP door (`treg_farm.py`) still creates accounts but **no longer pays the grant** — see below.
|
||||
|
||||
> Part of the free-tools series. More finds: [t.me/AlStack](https://t.me/AlStack)
|
||||
|
||||
## How it works (full protocol, reverse-engineered)
|
||||
## Why GitHub OAuth (the email door is dead for grants)
|
||||
|
||||
From the reversed backend: the email flow sets `promo_eligible = (turnstile_outcome == "PASS")`. Headless-obtained Turnstile tokens pass Cloudflare siteverify but are not classified `PASS` server-side, so email signups are created with `promo_eligible=False` → **$0**.
|
||||
|
||||
The GitHub OAuth door provisions the user via `find_or_create_user(...)` with `promo_eligible` defaulting to **True** — no captcha in the loop at all → **$1 grant fires on org creation**.
|
||||
|
||||
Observed hit rates: **69/69** on a pool with virgin inboxes, ~50–70% on mixed pools (see anti-fraud notes).
|
||||
|
||||
## Protocol (GitHub OAuth door)
|
||||
|
||||
```
|
||||
POST /auth/email/start {"email": "you+treg1@gmail.com"} -> {"sent": true}
|
||||
OTP: 6-digit code arrives in the email SUBJECT (sender treg.to)
|
||||
POST /auth/email/verify {"email", "code"} -> {"token"} + Set-Cookie session
|
||||
POST /orgs {"name": "myorg123"} [X-Treg-Token] -> org created, grant $1 (async ~2s)
|
||||
GET /auth/cli-token [X-Treg-Org: myorg123, SESSION COOKIE] -> {"token": <org_key>} <-- usable API key
|
||||
GET /orgs/{id}/balance [X-Treg-Token: org_key] -> {"balance_micro": 1000000}
|
||||
GET {base}/auth/github -> 302 github.com/login/oauth/authorize?client_id&state&redirect_uri
|
||||
+ Set-Cookie treg_oauth_state
|
||||
GH password + TOTP login (pure HTTP, no browser)
|
||||
GET <full authorize URL> -> code (direct 302 / meta-refresh page / consent POST authorize=1)
|
||||
GET {base}/auth/github/callback?code&state [Cookie: treg_oauth_state] -> treg_session cookie
|
||||
POST {base}/orgs {"name": "studioXXXX"} [session cookie] -> org_id + slug <-- $1 claim fires here
|
||||
GET {base}/auth/cli-token [X-Treg-Org: slug, session cookie] -> {"token": <team key>}
|
||||
GET {base}/orgs/{id}/balance [X-Treg-Token + X-Treg-Key-Protocol: 1] -> {"balance_micro": 1000000}
|
||||
```
|
||||
|
||||
All requests carry `X-Treg-Key-Protocol: 1`.
|
||||
Auth notes:
|
||||
- Balance/team endpoints require `X-Treg-Token: <key>` + `X-Treg-Key-Protocol: 1`. Plain `Authorization: Bearer` gets **401** on team resources.
|
||||
- Tokens minted before the Oct-2026 scopes deploy are BOOTSTRAP-scoped → **403 "finish team setup first"** on every team endpoint (balance included). Fresh logins mint proper team tokens.
|
||||
|
||||
### Pitfalls this toolkit solves
|
||||
## Anti-fraud notes (why some accounts get $0)
|
||||
|
||||
| Pitfall | Fix |
|
||||
|---|---|
|
||||
| `GET /auth/cli-token` returns **403** "a bootstrap token cannot mint a Default key" | Send the verify **session cookie only**, NO `X-Treg-Token` header on that request |
|
||||
| Org names containing `treg` are rejected | Neutral random names (`keynest983`, `gothlab331`, ...) |
|
||||
| Gmail IMAP `search` returns **stale** results | `m.noop()` before every search |
|
||||
| Re-issued `start` invalidates the previous code | Filter mails by `Date >= since_ts - 30` |
|
||||
| Render backend saturates (503 `treg_saturated: true`) | Exponential backoff retry on every call |
|
||||
| IP budget: 30 OTP starts / 15 min | Pacing 10–22 s between accounts, auto-cool 900 s on 429 |
|
||||
| Grant is per-**user**, once (DB-locked) | One Gmail `+alias` = one user = one $1 |
|
||||
- `SignupPromoClaim` is **unique per normalized inbox**: `+tag` is stripped for every domain, dots are stripped for gmail. One grant per mailbox, forever.
|
||||
- Retrying a $0 account with a second org does **not** pay again — the claim is already consumed.
|
||||
- Gmail `+alias` / dot-alias farms are therefore dead for this promo. Only genuinely fresh inboxes pay (separate real mailboxes, e.g. independent GH accounts with unique emails).
|
||||
- Flagged/suspended GitHub accounts bounce off `authorize` (redirect to `/dashboard` without a `code`) — the script reports it and moves on.
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
# Python 3.10+, only dependency: requests
|
||||
pip install requests
|
||||
# Python 3.10+
|
||||
pip install pyotp requests
|
||||
|
||||
# 1. create config
|
||||
cp config.example.json config.json
|
||||
# 2. edit config.json: put your Gmail address + IMAP app password
|
||||
# (Gmail: Security -> 2-Step Verification -> App passwords)
|
||||
cp config.example.json config.json # optional; env overrides work too
|
||||
|
||||
# GH pool: JSON array of accounts
|
||||
# [{"login": "...", "password": "...", "totp": "<base32 secret>", "email": "..."}]
|
||||
```
|
||||
|
||||
No secrets in the repo — `config.json` is gitignored. Env vars `TREG_IMAP_USER` / `TREG_IMAP_PASS` work too.
|
||||
No secrets in the repo — `config.json`, pools, banks and state files are gitignored.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# register accounts 1..30 (aliases you+treg1 ... you+treg30)
|
||||
python treg_farm.py 1 30
|
||||
# register N accounts from the pool (resumable via gh_reg_state.json)
|
||||
python gh_oauth_reg.py 25
|
||||
|
||||
# re-login accounts that have an org but no pinned key (recovers 403-stuck accounts)
|
||||
python treg_farm.py recover
|
||||
|
||||
# live-check the bank: balances + pinned keys
|
||||
python verify_bank.py
|
||||
# env overrides
|
||||
GH_POOL=/path/to/pool.json GH_STATE=my_state.json python gh_oauth_reg.py 50
|
||||
```
|
||||
|
||||
Output:
|
||||
- `treg_accounts.jsonl` — the bank: `{email, token, org_token, org, org_id, balance_micro, ts}`
|
||||
- `treg_farm_state.json` — resumable wave state (`registered` / `no_grant` / `failed`)
|
||||
- `treg_gh_bank.jsonl` — the bank: `{ts, email, gh_login, org, org_id, token, balance_usd, via}`
|
||||
- `gh_reg_state.json` — resumable pool index
|
||||
|
||||
Auto-stop: 4 consecutive accounts without grant. The wave is resumable — rerun with a new start index any time.
|
||||
Pacing is built in (8–15 s/account, `pace` in config.json).
|
||||
|
||||
## Using the keys
|
||||
|
||||
```bash
|
||||
# raw HTTP
|
||||
# tool calls take Bearer:
|
||||
curl https://treg.to/call/treg.web.search \
|
||||
-H "Authorization: Bearer ***" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"q": "hello world"}'
|
||||
|
||||
# team/balance endpoints take X-Treg-Token:
|
||||
curl "https://treg.to/orgs/<org_id>/balance?limit=3" \
|
||||
-H "X-Treg-Token: ***" -H "X-Treg-Key-Protocol: 1"
|
||||
|
||||
# official CLI
|
||||
pip install "tools-registry[proxy]"
|
||||
treg login --token ***
|
||||
treg call treg.x.user.posts --data '{"username": "elonmusk", "limit": 3}'
|
||||
treg balance
|
||||
```
|
||||
|
||||
Prices (live-verified): X user posts **$0.0005**, X search $0.00075, TikTok profile **$0.001**, web search **free** (19 providers), email verify free. Platform margin 0% — you pay provider cost. BYOK keys are unmetered.
|
||||
Prices (live-verified): X user posts **$0.0005**, X search $0.00075, TikTok profile **$0.001**, web search **free** (19 providers), image gen ~$0.04, video gen ~$0.21. Platform margin 0% — you pay provider cost. BYOK keys are unmetered.
|
||||
|
||||
## Rate limits (from source)
|
||||
## Legacy: email+OTP door (treg_farm.py / verify_bank.py)
|
||||
|
||||
- 30 OTP starts / 15 min / IP, 5 / email
|
||||
- 1 signup grant per user (not per IP) — alias farming is the intended scale path
|
||||
- Backend on Render: expect occasional 503 saturation windows
|
||||
Kept for reference. Flow: `POST /auth/email/start` → 6-digit OTP in the mail SUBJECT → `/auth/email/verify` → org → cli-token. Still registers fine, but grants are **$0** since the Turnstile-PASS gate (Oct 2026). Pitfalls it solves (IMAP `noop()` staleness, session-cookie-only cli-token mint, org-name filter, IP budget 30 starts/15 min, per-user grant lock) are documented in its file header.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user