73 lines
4.5 KiB
Markdown
73 lines
4.5 KiB
Markdown
# HF-MLH Toolkit
|
|
|
|
Raw-HTTP pipeline for MLH Hacktoberfest 2026 developer perks — no browser, no Selenium/Playwright for the claim flow. Pure `urllib` + Inertia.js protocol.
|
|
|
|
## Setup
|
|
|
|
```bash
|
|
cp config.example.json config.json # fill in IMAP_USER / IMAP_PASS
|
|
# or via env:
|
|
export IMAP_USER=you@gmail.com IMAP_PASS=<gmail app password>
|
|
export MAIL_ALIAS_BASE=you@gmail.com # base for +tag alias accounts
|
|
```
|
|
|
|
`config.json` is gitignored. Resolution order: env var → config.json → default.
|
|
All state lives under `./data/` (override with `TOOLKIT_DATA`); debug dumps under `./_work/`.
|
|
|
|
| File (under `data/`) | Purpose |
|
|
|---|---|
|
|
| `mlh_farm_accounts.jsonl` | input: one `{"email": ...}` per line |
|
|
| `hf_mlh_sessions.json` | MLH session cookies per email |
|
|
| `hf_hf_tokens.json` | Hacktoberfest API access/refresh tokens cache |
|
|
| `hf_claim_bank.jsonl` | results bank, resumable per email+sponsor |
|
|
|
|
## Scripts
|
|
|
|
1. **`hf_reauth2.py <tag_or_email> [wait_sec]`** — MLH re-auth via OTP: Turnstile (real-page solver) → `POST /signin` → `otpId` → 6-digit code from IMAP → `POST /signin/{otpId}/otp` → saves cookies to `hf_mlh_sessions.json`. (`hf_reauth.py` is the older magic-link variant.)
|
|
2. **`hf_refresh.py [email]`** — refresh cached HF API tokens via `POST /auth/refresh`. **No MLH auth, no browser, no email** — as long as a `refreshToken` is cached, this keeps the pipeline alive. Run before a claim wave. Exit 0 = at least one refreshed, 2 = all failed.
|
|
3. **`hf_raw_claim.py [start] [count]`** — full claim chain per account:
|
|
- `mlh_token` from sessions (else OTP reauth fallback, cookies are persisted back)
|
|
- OAuth: `GET hacktoberfest-api.mlh.com/oauth/mlh` → Inertia `authorize` POST on `www.mlh.com` → **409 + `x-inertia-location`** (lowercase header) = external code → callback 302 → **internal 64-hex code** → `POST /auth/token`
|
|
- `GET /api/me/offers` → per-sponsor `claim-link` → redeem page props (`token`, `redeemUrl`, `unmetClaimRequirements`) → Inertia POST redeem → `promoCode`
|
|
- Bank is resumable: claimed/blocked entries are skipped on re-run.
|
|
4. **`hf_promos.py <idx> [--claim]`** — legacy single-account variant (magic-link reauth + offers dump).
|
|
|
|
Typical wave:
|
|
|
|
```bash
|
|
python hf_refresh.py # revive all cached tokens
|
|
python hf_raw_claim.py 0 26 # claim everything unblocked for accounts 0..25
|
|
```
|
|
|
|
## Perks status (26 tested accounts)
|
|
|
|
| Sponsor | Value | Status |
|
|
|---|---|---|
|
|
| Backboard | $5 | auto-claimed 26/26 (redeem code on backboard.io) |
|
|
| Render | $50 | auto-claimed 26/26 (credits portal, claim by Nov 15) |
|
|
| .tech domain | 1 yr free | blocked: `verified_phone` + `github_oauth` |
|
|
| Thinking Machines (Tinker) | $10 | blocked: `verified_phone` + `github_oauth` |
|
|
| ElevenLabs / SpaceXAI | challenges | no promo pool — challenge-only offers |
|
|
|
|
The `verified_phone` gate is **not** bypassed by this toolkit — phone-gated perks stay `blocked` in the bank. Note: Thinking Machines credits are for **Tinker** (their open-weight hosting), not an Anthropic/Claude API.
|
|
|
|
## Key protocol findings
|
|
|
|
- The `authorize` POST answers **409 with `x-inertia-location`** (lowercase!) containing the external OAuth code — not an error, it's Inertia's external-redirect convention.
|
|
- The callback URL's code is **not** the token-exchange code: `GET .../oauth/mlh/callback?code=<ext>` → 302 `hacktoberfest.com/auth/callback?code=<internal 64-hex>`; only the internal code works on `POST /auth/token`.
|
|
- Seed **only** `mlh_token` into a fresh cookie jar — stale session cookies cause `422 transaction-invalid`.
|
|
- Stale `X-Inertia-Version` on any Inertia POST → bare 409 with no Location: re-GET the page first.
|
|
- OTP POST can return 409 **after** the code was consumed and the session signed — re-check `isSignedIn` before retrying.
|
|
- HF `accessToken` expires in ~days; `refreshToken` survives much longer — `hf_refresh.py` revives a whole farm without touching MLH.
|
|
|
|
## Requirements
|
|
|
|
- Python 3.11+, **stdlib only** (`urllib`, `imaplib`, `quopri`, `json`).
|
|
- A Gmail mailbox with an [app password](https://myaccount.google.com/apppasswords) (farm accounts are `+tag` aliases of it).
|
|
- Turnstile solving (reauth step only): local real-page solver on `127.0.0.1:8877` (`SIDECAR_URL`), optional 2captcha fallback (`TWO_CAPTCHA_KEY` or `data/captcha_keys_2captcha.json`). MLH's siteverify rejects plain headless tokens — `real_page: true` is mandatory.
|
|
|
|
## Farm notes
|
|
|
|
- MLH bans plus-tag alias farms in batches; pace waves and expect attrition.
|
|
- Bank records keyed by `(email, sponsor)` — safe to re-run any wave.
|