Repository navigation
Authenticate with a browser session (token + cookie) - #7
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thedsession cookie.Changes
--cookieoption (andSLACK_COOKIEenv var) that sets thedcookie on therequests.Sessionslacker uses.dvalue URL-encoded; sending it decoded fails withinvalid_auth._normalize_d_cookiere-encodes idempotently (quote(unquote(...))), so it works whether the value is pasted encoded (Network tab) or decoded (cookie inspector), and it also extractsdfrom a fullCookie:header.xoxc-token from the console +dcookie from DevTools), recommending--dry-runand theSLACK_TOKEN/SLACK_COOKIEenv vars.Verification
Confirmed end-to-end against a live workspace: the CLI authenticates and
search.messagesreturns results (--dry-runreportedFound 106 itemsfor a date window). The whole bug was that we'd been URL-decoding thedcookie.pyright strict clean; 17 tests pass; pre-commit clean.