tweepy.errors.Forbidden:403 Forbidden - 使用 Tweepy 的 Twitter API 身份验证问题

Dan*_*Dan 4 python twitter tweepy

我正在遇到

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.
Run Code Online (Sandbox Code Playgroud)

尝试运行以下代码,使用 Twitter API 和 Tweepy 获取用户的帖子历史记录:

    client = tweepy.Client(bearer_token=bearer_token)
    tweets = client.search_recent_tweets(query=f'from:{user_handle}')
Run Code Online (Sandbox Code Playgroud)

我的应用程序似乎确实连接到了一个项目(参见 img),我遇到了一些链接,表明这可能是与 API 身份验证相关的 Twitter 问题。但是,我想确认是否确实如此,以及是否有任何可能的解决方案或解决方法来解决此问题。

表明这可能是 Twitter 问题的链接:

https://github.com/twitterdev/Twitter-API-v2-sample-code/issues/58 https://twittercommunity.com/t/when-authenticating-requests-to-the-twitter-api-v2-endpoints -您必须使用附加到项目的 Twitter 开发人员应用程序中的密钥和令牌,您可以通过开发人员创建项目-传送门/189699

我将非常感谢任何解决此问题的见解、解释或潜在解决方案。

在此输入图像描述

Mar*_*nen 7

您的应用程序具有免费访问层,仅允许:

  • 使用 Twitter API v2 发布推文
  • 使用 Twitter API v1.1 上传媒体并登录 Twitter

要执行其他操作,您至少需要基本访问层,这需要花费一些钱。

访问层记录在https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api

当然,您应该使用支持 V2 API 的最新版本的 Tweepy。

  • 好吧,我现在明白为什么我的代码不起作用,这对于该平台来说是非常悲伤的!谢谢埃隆。 (4认同)