twikit icon indicating copy to clipboard operation
twikit copied to clipboard

Twikit requests now always return Cloudflare 403 even with fresh cookies

Open bshsbr opened this issue 1 month ago • 6 comments

All cookie-based calls (client.user(), timelines, etc.) now die with twikit.errors.Forbidden: status: 403 and the Cloudflare block HTML, even after:

fresh cookie export (auth_token, ct0, twid, etc.) Chrome UA + custom TLS context (ssl + httpx.AsyncHTTPTransport, TLS 1.2–1.3, ALPN ["h2","http/1.1"], Chrome cipher suite) same machine/IP where the browser works fine (browser never sees a challenge, so no cf_clearance to copy) Are other folks seeing the same wall? If you’re still able to use Twikit, are you solving Cloudflare somehow (cf_clearance, solver, different proxy), or did tweaking TLS/UA alone work for you? Looking for confirmation before I keep digging.

bshsbr avatar Nov 10 '25 17:11 bshsbr

I have been getting 404s

ObiAU avatar Nov 11 '25 18:11 ObiAU

[2025-11-14 20:20:39] Bot 1: ‼ Forbidden: status: 403, message: "<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<title>Attention Required! | Cloudflare</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" />
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" /><![endif]-->
<style>body{margin:0;padding:0}</style>


<!--[if gte IE 10]><!-->
<script>
  if (!navigator.cookieEnabled) {
    window.addEventListener('DOMContentLoaded', function () {
      var cookieEl = document.getElementById('cookie-alert');
      cookieEl.style.display = 'block';
    })
  }
</script>
<!--<![endif]-->

</head>
<body>
  <div id="cf-wrapper">
    <div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
    <div id="cf-error-details" class="cf-error-details-wrapper">
      <div class="cf-wrapper cf-header cf-error-overview">
        <h1 data-translate="block_headline">Sorry, you have been blocked</h1>
        <h2 class="cf-subheadline"><span data-translate="unable_to_access">You are unable to access</span> x.com</h2>
      </div><!-- /.header -->

      <div class="cf-section cf-highlight">
        <div class="cf-wrapper">
          <div class="cf-screenshot-container cf-screenshot-full">
            
              <span class="cf-no-screenshot error"></span>
            
          </div>
        </div>
      </div><!-- /.captcha-container -->

      <div class="cf-section cf-wrapper">
        <div class="cf-columns two">
          <div class="cf-column">
            <h2 data-translate="blocked_why_headline">Why have I been blocked?</h2>

            <p data-translate="blocked_why_detail">This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.</p>
          </div>

          <div class="cf-column">
            <h2 data-translate="blocked_resolve_headline">What can I do to resolve this?</h2>

            <p data-translate="blocked_resolve_detail">You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.</p>
          </div>
        </div>
      </div><!-- /.section -->

      <div class="cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300">
    <p class="text-13">
      <span class="cf-footer-item sm:block sm:mb-1">Cloudflare Ray ID: <strong class="font-semibold">99e7d64d290b410d</strong></span>
      <span class="cf-footer-separator sm:hidden">&bull;</span>
      <span id="cf-footer-item-ip" class="cf-footer-item hidden sm:block sm:mb-1">
        Your IP:
        <button type="button" id="cf-footer-ip-reveal" class="cf-footer-ip-reveal-btn">Click to reveal</button>
        <span class="hidden" id="cf-footer-ip">5.77.215.109</span>
        <span class="cf-footer-separator sm:hidden">&bull;</span>
      </span>
      <span class="cf-footer-item sm:block sm:mb-1"><span>Performance &amp; security by</span> <a rel="noopener noreferrer" href="https://www.cloudflare.com/5xx-error-landing" id="brand_link" target="_blank">Cloudflare</a></span>
      
    </p>
    <script>(function(){function d(){var b=a.getElementById("cf-footer-item-ip"),c=a.getElementById("cf-footer-ip-reveal");b&&"classList"in b&&(b.classList.remove("hidden"),c.addEventListener("click",function(){c.classList.add("hidden");a.getElementById("cf-footer-ip").classList.remove("hidden")}))}var a=document;document.addEventListener&&a.addEventListener("DOMContentLoaded",d)})();</script>
  </div><!-- /.error-footer -->

    </div><!-- /#cf-error-details -->
  </div><!-- /#cf-wrapper -->

  <script>
    window._cf_translation = {};
    
    
  </script>
</body>
</html>"
[2025-11-14 20:20:39] Bot 1:     traceback:
    Traceback (most recent call last):
      File "C:\Users\Auditor\Desktop\everything\PY\selfbot.py", line 885, in _net
        return self.loop.run_until_complete(safe_twikit_call(coro))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2800.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 691, in run_until_complete
        return future.result()
               ^^^^^^^^^^^^^^^
      File "C:\Users\Auditor\Desktop\everything\PY\selfbot.py", line 188, in _inner
        return await awaitable
               ^^^^^^^^^^^^^^^
      File "C:\Users\Auditor\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\twikit\client\client.py", line 690, in user
        return await self.get_user_by_id(await self.user_id())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Auditor\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\twikit\client\client.py", line 1438, in get_user_by_id
        response, _ = await self.gql.user_by_rest_id(user_id)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Auditor\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\twikit\client\gql.py", line 260, in user_by_rest_id
        return await self.gql_get(Endpoint.USER_BY_REST_ID, variables, USER_FEATURES)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Auditor\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\twikit\client\gql.py", line 124, in gql_get
        return await self.base.get(url, params=flatten_params(params), headers=headers, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Auditor\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\twikit\client\client.py", line 223, in get
        return await self.request('GET', url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\Auditor\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\twikit\client\client.py", line 202, in request
        raise Forbidden(message, headers=response.headers)
    twikit.errors.Forbidden: status: 403, message: "<!DOCTYPE html>
    <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
    <!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
    <!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
    <!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
    <head>
    <title>Attention Required! | Cloudflare</title>
    <meta charset="UTF-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta name="robots" content="noindex, nofollow" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" />
    <!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" /><![endif]-->
    <style>body{margin:0;padding:0}</style>


    <!--[if gte IE 10]><!-->
    <script>
      if (!navigator.cookieEnabled) {
        window.addEventListener('DOMContentLoaded', function () {
          var cookieEl = document.getElementById('cookie-alert');
          cookieEl.style.display = 'block';
        })
      }
    </script>
    <!--<![endif]-->

    </head>
    <body>
      <div id="cf-wrapper">
        <div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
        <div id="cf-error-details" class="cf-error-details-wrapper">
          <div class="cf-wrapper cf-header cf-error-overview">
            <h1 data-translate="block_headline">Sorry, you have been blocked</h1>
            <h2 class="cf-subheadline"><span data-translate="unable_to_access">You are unable to access</span> x.com</h2>
          </div><!-- /.header -->

          <div class="cf-section cf-highlight">
            <div class="cf-wrapper">
              <div class="cf-screenshot-container cf-screenshot-full">
            
                  <span class="cf-no-screenshot error"></span>
            
              </div>
            </div>
          </div><!-- /.captcha-container -->

          <div class="cf-section cf-wrapper">
            <div class="cf-columns two">
              <div class="cf-column">
                <h2 data-translate="blocked_why_headline">Why have I been blocked?</h2>

                <p data-translate="blocked_why_detail">This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.</p>
              </div>

              <div class="cf-column">
                <h2 data-translate="blocked_resolve_headline">What can I do to resolve this?</h2>

                <p data-translate="blocked_resolve_detail">You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.</p>
              </div>
            </div>
          </div><!-- /.section -->

          <div class="cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300">
        <p class="text-13">
          <span class="cf-footer-item sm:block sm:mb-1">Cloudflare Ray ID: <strong class="font-semibold">99e7d64d290b410d</strong></span>
          <span class="cf-footer-separator sm:hidden">&bull;</span>
          <span id="cf-footer-item-ip" class="cf-footer-item hidden sm:block sm:mb-1">
            Your IP:
            <button type="button" id="cf-footer-ip-reveal" class="cf-footer-ip-reveal-btn">Click to reveal</button>
            <span class="hidden" id="cf-footer-ip">5.77.215.109</span>
            <span class="cf-footer-separator sm:hidden">&bull;</span>
          </span>
          <span class="cf-footer-item sm:block sm:mb-1"><span>Performance &amp; security by</span> <a rel="noopener noreferrer" href="https://www.cloudflare.com/5xx-error-landing" id="brand_link" target="_blank">Cloudflare</a></span>
      
        </p>
        <script>(function(){function d(){var b=a.getElementById("cf-footer-item-ip"),c=a.getElementById("cf-footer-ip-reveal");b&&"classList"in b&&(b.classList.remove("hidden"),c.addEventListener("click",function(){c.classList.add("hidden");a.getElementById("cf-footer-ip").classList.remove("hidden")}))}var a=document;document.addEventListener&&a.addEventListener("DOMContentLoaded",d)})();</script>
      </div><!-- /.error-footer -->

        </div><!-- /#cf-error-details -->
      </div><!-- /#cf-wrapper -->

      <script>
        window._cf_translation = {};
    
    
      </script>
    </body>
    </html>"

Auditormadness9 avatar Nov 14 '25 16:11 Auditormadness9

Of course, the day I pick it up. Anybody have a working example?

science-cat avatar Nov 15 '25 14:11 science-cat

I've been troubled by this problem for several days. I've tried many solutions but couldn't fix it. I also attempted to contact the repository's author, but unfortunately, I haven't received a response. However, I finally found a paid solution, and the price is quite reasonable. I don't want to waste any more of my time. twitter_login

XAICH avatar Nov 17 '25 17:11 XAICH

Another method is TakionAPI free trial

CODIW9 avatar Nov 17 '25 18:11 CODIW9

I've been using twitter-openapi-python. Bit less intuitive to use, but fully functional?

science-cat avatar Nov 17 '25 19:11 science-cat

Still facing the same problem, somebody found a solution?

AritzUMA avatar Dec 09 '25 17:12 AritzUMA