Skip to content

Cookie Authentication/Persistence Issues #144

@alireza-sharifpour

Description

@alireza-sharifpour

Bug Description:
Saved authentication cookies cannot be successfully reused for subsequent sessions. The library saves cookies but fails to authenticate with them on reload.

Expected Behavior:
After successful authentication, saved cookies should allow authentication in future sessions without requiring username/password.

Actual Behavior:

  • Cookies are saved successfully after password authentication
  • When loaded in a new session, setCookies() accepts the cookies
  • However, isLoggedIn() returns false despite cookies being set
  • Forces fallback to password authentication every time

Environment:

  • Package: @the-convocation/twitter-scraper
  • Node.js version: v23.5.0
  • Platform: macOS

Code Example:

  // After successful password auth, cookies are saved:
  const cookies = await scraper.getCookies();
  fs.writeFileSync('cookies.json', JSON.stringify(cookies, null, 2));


  // Next session - loading cookies fails:
  const savedCookies = JSON.parse(fs.readFileSync('cookies.json', 'utf8'));
  await scraper.setCookies(savedCookies); // No error
  const isLoggedIn = await scraper.isLoggedIn(); // Returns false

Impact:

  • Applications must re-authenticate with username/password every session
  • Cannot take advantage of cookie-based session persistence
  • Increased load on Twitter's authentication endpoints
  • Slower startup times for applications

Workaround:
Currently falling back to password authentication, but this defeats the purpose of cookie persistence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions