Skip to content

Authenticate with a browser session (token + cookie) - #7

Merged
bboe merged 1 commit into
mainfrom
add-cookie-auth
Jun 15, 2026
Merged

bboe merged 1 commit into
mainfrom
add-cookie-auth

Conversation

@bboe

@bboe bboe commented Jun 15, 2026 •

Copy link
Copy Markdown
Owner

deslackify is meant to be run without the overhead of creating a Slack app, so it authenticates as the user's browser session: an xoxc- token plus the d session cookie.

Changes

  • --cookie option (and SLACK_COOKIE env var) that sets the d cookie on the requests.Session slacker uses.
  • Cookie normalization — Slack only accepts the d value URL-encoded; sending it decoded fails with invalid_auth. _normalize_d_cookie re-encodes idempotently (quote(unquote(...))), so it works whether the value is pasted encoded (Network tab) or decoded (cookie inspector), and it also extracts d from a full Cookie: header.
  • README rewritten around the browser-session flow (grab xoxc- token from the console + d cookie from DevTools), recommending --dry-run and the SLACK_TOKEN/SLACK_COOKIE env vars.
  • Tests for normalization (encode/idempotent/header-extraction) and session wiring.

Verification

Confirmed end-to-end against a live workspace: the CLI authenticates and search.messages returns results (--dry-run reported Found 106 items for a date window). The whole bug was that we'd been URL-decoding the d cookie.

pyright strict clean; 17 tests pass; pre-commit clean.

@bboe
bboe force-pushed the add-cookie-auth branch from cad3611 to 48a385f Compare June 15, 2026 06:40
deslackify is meant to be run without the overhead of creating a Slack
app, so it authenticates as the user's browser session: an xoxc- token
plus the d session cookie.

- Add a --cookie option (and SLACK_COOKIE environment variable) that sets
  the d cookie on the requests session that slacker uses.
- Normalize the d cookie value via quote(unquote(...)): Slack only accepts
  it URL-encoded, and this idempotent re-encoding works whether the value
  is pasted in its encoded (network request) or decoded (cookie inspector)
  form. Sending the decoded value is rejected with invalid_auth.
- Document obtaining the xoxc- token and d cookie from the browser, and
  recommend --dry-run plus the SLACK_TOKEN/SLACK_COOKIE env vars.
- Add unit tests for the cookie normalization and session wiring.
@bboe
bboe force-pushed the add-cookie-auth branch from 48a385f to e8ae44f Compare June 15, 2026 06:44
@bboe
bboe merged commit 650a3df into main Jun 15, 2026
6 checks passed
@bboe
bboe deleted the add-cookie-auth branch June 15, 2026 06:46
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