Authentication
The default google backend requires no authentication at all — you can start searching immediately after install. Auth exists only for two optional cases:
- The
serpapibackend — needs a SerpApi API key. - CAPTCHA recovery — an optional
GOOGLE_ABUSE_EXEMPTIONcookie that can lift a soft-block on thegooglebackend.
# Check whether you need to do anythinggfly auth status
# Store a SerpApi key (secret read from stdin, never an arg)echo "$SERPAPI_KEY" | gfly auth login --token-stdin
# Remove the locally stored keygfly auth logout --backend serpapiauth login
Section titled “auth login”Stores a credential in the OS keyring (file fallback on headless systems). Secrets are stdin-only — passing them as command-line flags is intentionally not supported because flags leak into ps, /proc, and shell history.
# SerpApi keyecho "$SERPAPI_KEY" | gfly auth login --token-stdin
# CAPTCHA-recovery cookie (google backend)echo "$COOKIE_VALUE" | gfly auth login --abuse-cookie-stdinFlags:
| Flag | What it does |
|---|---|
--token-stdin |
Read the SerpApi key from stdin |
--abuse-cookie-stdin |
Read a GOOGLE_ABUSE_EXEMPTION cookie from stdin (CAPTCHA recovery) |
On success gfly emits {"ok": true, "kind": "...", "stored": "..."} where stored is either "keyring" or the path of the file that was written.
auth status
Section titled “auth status”Checks whether the active backend has valid credentials and prints the result without revealing the secret.
gfly auth status # uses the default (google) backendgfly auth status --backend serpapi # checks for a SerpApi keyFor the google backend the response is always authenticated: true (no key needed). For serpapi it resolves the key through the full lookup chain and exits non-zero with AUTH_REQUIRED (exit 4) if nothing is found, along with a remediation hint.
auth logout
Section titled “auth logout”Removes the locally stored credential. It does not revoke the key at the provider.
gfly auth logout --backend serpapi # removes the stored SerpApi keygfly auth logout --backend google # removes the stored abuse cookieWhere secrets live
Section titled “Where secrets live”Resolution order (first match wins):
| Priority | Source | How to set |
|---|---|---|
| 1 | Environment variable | GFLY_SERPAPI_KEY / GFLY_ABUSE_COOKIE |
| 2 | OS keyring | Written by gfly auth login |
| 3 | 0600 XDG file |
$XDG_CONFIG_HOME/gfly/credentials (default ~/.config/gfly/credentials) |
auth login always tries the OS keyring first. If the keyring is unavailable (common on headless servers), it falls through to the file without error. gfly never crashes on a missing keyring backend.
If the file is created but its permissions are wider than 0600, gfly prints a warning on stderr and tells you how to fix it:
WARNING: /home/you/.config/gfly/credentials is 0644; want 0600. Run: chmod 600 /home/you/.config/gfly/credentialsEnvironment variables
Section titled “Environment variables”You can skip auth login entirely by exporting credentials in your shell or CI environment:
export GFLY_SERPAPI_KEY="your-key-here"gfly search JFK LHR --depart 2026-07-15 --backend serpapi# In a CI pipeline (e.g. GitHub Actions)env: GFLY_SERPAPI_KEY: ${{ secrets.SERPAPI_KEY }}The full list of auth-related env vars:
| Variable | Purpose |
|---|---|
GFLY_SERPAPI_KEY |
SerpApi API key |
GFLY_ABUSE_COOKIE |
GOOGLE_ABUSE_EXEMPTION cookie value |
GFLY_BACKEND |
Set the default backend (google or serpapi) |
CAPTCHA recovery cookie
Section titled “CAPTCHA recovery cookie”If the google backend is soft-blocked by Google (you see CAPTCHA-related errors), you can supply a GOOGLE_ABUSE_EXEMPTION cookie obtained from a logged-in browser session. This is a workaround, not a guarantee.
# Store via auth loginecho "$COOKIE" | gfly auth login --backend google --abuse-cookie-stdin
# Or export directlyexport GFLY_ABUSE_COOKIE="your-cookie-value"The cookie follows the same storage resolution order (env → keyring → file) as the SerpApi key.
Headless and CI environments
Section titled “Headless and CI environments”On machines without a desktop keyring (Docker containers, CI runners, remote servers), gfly detects that no keyring backend is available and degrades gracefully to the 0600 file or the environment variable. It logs this to stderr but never raises an error.
The recommended approach for headless use:
- Set
GFLY_SERPAPI_KEYas a secret environment variable in your CI/CD system. - Never write the key to disk in CI; rely on the env var alone.
- Run
gfly doctorto confirm the key is found and which path is in use.
Diagnosing with doctor
Section titled “Diagnosing with doctor”gfly doctor reports the full auth state alongside throttle and connectivity checks:
gfly doctor --backend serpapiExample output (JSON, truncated):
{ "checks": [ { "name": "auth", "ok": true, "detail": "ok" }, { "name": "keyring", "ok": false, "detail": "no OS keyring backend; using env / 0600 file fallback" }, { "name": "throttle","ok": true, "detail": "clear" } ]}The auth check resolves the credential through the full lookup chain and reports ok or the exact remediation step needed. keyring reports which storage path is active. See Rate limits & bans for the throttle fields.