Add cookies.txt authentication support
All checks were successful
CI / test (3.10) (push) Successful in 1m51s
CI / test (3.11) (push) Successful in 29s
CI / test (3.12) (push) Successful in 24s

This commit is contained in:
2026-05-08 16:43:01 +02:00
parent 7c634e0d39
commit bc82333e07
5 changed files with 138 additions and 7 deletions

View File

@@ -174,7 +174,22 @@ twitter follow elonmusk --json
twitter-cli uses this auth priority:
1. **Environment variables**: `TWITTER_AUTH_TOKEN` + `TWITTER_CT0`
2. **Browser cookies** (recommended): auto-extract from Arc/Chrome/Edge/Firefox/Brave
2. **Cookie file**: `TWITTER_COOKIE_FILE` or `config.yaml -> auth.cookieFile`
3. **Browser cookies** (recommended): auto-extract from Arc/Chrome/Edge/Firefox/Brave
If you already exported a Netscape-format `cookies.txt`, point the CLI at it:
```bash
export TWITTER_COOKIE_FILE=/path/to/cookies.txt
twitter whoami
```
Or in `config.yaml`:
```yaml
auth:
cookieFile: /path/to/cookies.txt
```
Browser extraction is recommended — it forwards ALL Twitter cookies (not just `auth_token` + `ct0`) and aligns request headers with your local runtime, which is closer to normal browser traffic than minimal cookie auth.