Skip to content

Fetch homepage authenticated for ClientTransaction init - #89

Open
GodfreyPrince wants to merge 1 commit into
public-clis:mainfrom
GodfreyPrince:fix-authenticated-ct-init
Open

Fetch homepage authenticated for ClientTransaction init#89
GodfreyPrince wants to merge 1 commit into
public-clis:mainfrom
GodfreyPrince:fix-authenticated-ct-init

Conversation

@GodfreyPrince

Copy link
Copy Markdown

Problem

twitter search (and any endpoint requiring x-client-transaction-id) fails with HTTP 404, even with a fresh live SearchTimeline queryId from the community openapi file.

Root cause

_ensure_client_transaction fetches https://x.com anonymously. The logged-out homepage no longer embeds either artifact xclienttransaction parses:

  • the ondemand.* webpack chunk map (ON_DEMAND_FILE_REGEX finds nothing, so .group(1) raises NoneType has no attribute group, swallowed as a warning), and
  • the loading-x-anim SVG frames.

So ClientTransaction never initializes, no x-client-transaction-id header is ever sent, and the search endpoint 404s every request. Feed/user endpoints do not require the header, which is why only search broke.

Fix

Send the account Cookie + X-Csrf-Token with the init fetch. The logged-in homepage contains the chunk map, the animation frames, and the twitter-site-verification meta, so init succeeds.

Verified end-to-end on Windows (Brave 152, Python 3.13): the Failed to init ClientTransaction warning is gone and twitter search "AI agent" -t Latest returns ok: true.

The logged-out x.com homepage no longer embeds the ondemand chunk map
or loading-x-anim frames that xclienttransaction parses, so the
anonymous fetch in _ensure_client_transaction always failed init and no
x-client-transaction-id header was ever generated. The search endpoint
rejects such requests with HTTP 404 even with a fresh live queryId,
while feed/user endpoints kept working.

Send the account Cookie + X-Csrf-Token with the init fetch so the
logged-in page (which contains all three markers) is parsed instead.
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