Skip to content

fix: use account cookies for XClId asset requests - #321

Merged
vladkens merged 3 commits into
vladkens:mainfrom
jonsuh:fix/authenticated-xclid
Jul 21, 2026
Merged

fix: use account cookies for XClId asset requests#321
vladkens merged 3 commits into
vladkens:mainfrom
jonsuh:fix/authenticated-xclid

Conversation

@jonsuh

@jonsuh jonsuh commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes issue #320 that was causing the following error:

WARNING  | twscrape.queue_client:get:40 - XClIdGen creation attempt 1/3 failed: Exception: Couldn't get XClientTxId indices script

Changes

  • Modify XClIdGen.create() and XClIdGenStore.get() to use cookies so they fetch from authenticated sessions.
  • Update main() demo to accept cookies and fail gracefully via warning if unset.

Tests

  • Add cookie test coverage for both XClIdGen.create() and XClIdGenStore.get() in tests/test_xclid.py and tests/test_queue_client.py respectively.

peaceplayer0722 pushed a commit to peaceplayer0722/twscrape that referenced this pull request Jul 21, 2026
X now serves a web bundle without the sign.o-*.js / ondemand.s-*.js
indices script to anonymous sessions, so the anonymous fetch in
XClIdGen.create failed with "Couldn't get XClientTxId indices script"
and every GraphQL request 404'd. Thread account cookies through
XClIdGenStore.get -> XClIdGen.create so the fetch runs under the
account's authenticated session.

Ref: vladkens#321
gepard-me pushed a commit to gepard-me/twscrape that referenced this pull request Jul 21, 2026
X now serves a web bundle without the sign.o-*.js / ondemand.s-*.js
indices script to anonymous sessions, so the anonymous fetch in
XClIdGen.create failed with "Couldn't get XClientTxId indices script"
and every GraphQL request 404'd. Thread account cookies through
XClIdGenStore.get -> XClIdGen.create so the fetch runs under the
account's authenticated session.

Ref: vladkens#321
@vladkens vladkens changed the title Fix XClIdGen.create() to always use authenticated sessions/cookies fix: use account cookies for XClId asset requests Jul 21, 2026
@vladkens

Copy link
Copy Markdown
Owner

Thanks for tracking this down and fixing it! Great first contribution to twscrape 🎉

@vladkens
vladkens merged commit f4423d6 into vladkens:main Jul 21, 2026
5 checks passed
@jonsuh
jonsuh deleted the fix/authenticated-xclid branch July 21, 2026 15:56
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.

2 participants