Skip to content

Backfill Reddit credentials from X-Apollo-Reddit-* headers on account upserts - #12

Merged
nickclyde merged 1 commit into
mainfrom
upsert-creds-headers
Jul 14, 2026
Merged

Backfill Reddit credentials from X-Apollo-Reddit-* headers on account upserts#12
nickclyde merged 1 commit into
mainfrom
upsert-creds-headers

Conversation

@nickclyde

Copy link
Copy Markdown
Collaborator

Problem

Account upserts can arrive without reddit_client_id (422 missing required credentials, has_client_id: false) even when the user has an API key configured: the tweak's NSData-based body augmentation can't reach bodies attached to upload/data tasks via fromData:, so Apollo's raw payload — which never carried the reddit_* fields — hits the wire unmodified. The existing REDDIT_CLIENT_ID env fallback only helps deployments whose users all share that one key.

Fix

  • The tweak now sends its global-default credentials as X-Apollo-Reddit-Client-Id / -Client-Secret / -Redirect-Uri / -User-Agent headers on every account upsert (companion PR: Notifications: carry Reddit credentials in headers on account upserts Apollo-Reborn#642 — same pattern as X-Apollo-Transport on /v1/device). Backfill missing fields from those headers in both upsert handlers, between body fields and the env fallback: body > header > env, so per-account overrides in an augmented body still win.
  • Give the singular upsert handler the same defensive missing-credentials 422 the bulk handler has — registerAccountNewAuthenticatedClient panics on empty tokens, and unaugmented singular upserts hit exactly that path.

Testing

go build ./... and go vet ./internal/api/ clean.

… upserts

The tweak's JSON body augmentation can't reach bodies attached to
upload/data tasks via fromData:, so registrations can arrive without
reddit_client_id and 422 even though the user has an API key set. The
tweak now also sends its global-default credentials as
X-Apollo-Reddit-* headers (same pattern as X-Apollo-Transport on
/v1/device); backfill missing fields from them, between body fields and
the env-var fallback (body > header > env).

Also give the singular upsert handler the same defensive
missing-credentials 422 the bulk handler has — registerAccount's
NewAuthenticatedClient panics on empty tokens.
@nickclyde
nickclyde merged commit 392be17 into main Jul 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant