Skip to content

403 from X (Twitter) #425

Description

@knatten

Just got this error:

Publishing question 419
Posting to X: 'We just published a new question! Follow us on Bluesky @cppquiz.bsky.social or Mastodon @cppquiz@mastodon.online for updates. For obvious reasons, no longer post to Elon Musk's X.'
Traceback (most recent call last):
  File "/home/dh_8p7d44/sites/[cppquiz.org/cppquiz/manage.py](http://cppquiz.org/cppquiz/manage.py)", line 10, in <module>
    execute_from_command_line(sys.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/home/dh_8p7d44/sites/[cppquiz.org/venv/lib/python3.13/site-packages/django/core/management/__init__.py](http://cppquiz.org/venv/lib/python3.13/site-packages/django/core/management/__init__.py)", line 442, in execute_from_command_line
    utility.execute()
    ~~~~~~~~~~~~~~~^^
  File "/home/dh_8p7d44/sites/[cppquiz.org/venv/lib/python3.13/site-packages/django/core/management/__init__.py](http://cppquiz.org/venv/lib/python3.13/site-packages/django/core/management/__init__.py)", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/home/dh_8p7d44/sites/[cppquiz.org/venv/lib/python3.13/site-packages/django/core/management/base.py](http://cppquiz.org/venv/lib/python3.13/site-packages/django/core/management/base.py)", line 420, in run_from_argv
    self.execute(*args, **cmd_options)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dh_8p7d44/sites/[cppquiz.org/venv/lib/python3.13/site-packages/django/core/management/base.py](http://cppquiz.org/venv/lib/python3.13/site-packages/django/core/management/base.py)", line 464, in execute
    output = self.handle(*args, **options)
  File "/home/dh_8p7d44/sites/[cppquiz.org/cppquiz/quiz/management/commands/auto_publish.py](http://cppquiz.org/cppquiz/quiz/management/commands/auto_publish.py)", line 31, in handle
    self.post_to_x()
    ~~~~~~~~~~~~~~^^
  File "/home/dh_8p7d44/sites/[cppquiz.org/cppquiz/quiz/management/commands/auto_publish.py](http://cppquiz.org/cppquiz/quiz/management/commands/auto_publish.py)", line 44, in post_to_x
    response = client.create_tweet(
        text=content
    )
  File "/home/dh_8p7d44/sites/[cppquiz.org/venv/lib/python3.13/site-packages/tweepy/client.py](http://cppquiz.org/venv/lib/python3.13/site-packages/tweepy/client.py)", line 845, in create_tweet
    return self._make_request(
           ~~~~~~~~~~~~~~~~~~^
        "POST", f"/2/tweets", json=json, user_auth=user_auth
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/dh_8p7d44/sites/[cppquiz.org/venv/lib/python3.13/site-packages/tweepy/client.py](http://cppquiz.org/venv/lib/python3.13/site-packages/tweepy/client.py)", line 129, in _make_request
    response = self.request(method, route, params=request_params,
                            json=json, user_auth=user_auth)
  File "/home/dh_8p7d44/sites/[cppquiz.org/venv/lib/python3.13/site-packages/tweepy/client.py](http://cppquiz.org/venv/lib/python3.13/site-packages/tweepy/client.py)", line 100, in request
    raise Forbidden(response)
tweepy.errors.Forbidden: 403 Forbidden
When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.

Edit, fixed: We_ should also make sure an error in one of these posting functions in quiz/management/commands/auto_publish.py doesn't stop the other ones from being called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions