【问题标题】:Tweepy App Engine example raises 401 exceptionTweepy App Engine 示例引发 401 异常
【发布时间】:2013-04-12 13:11:06
【问题描述】:

我在这里使用 tweepy google 应用引擎示例作为我的应用程序的基础:https://github.com/tweepy/examples/tree/master/appengine

get_authorization_url()方法触发401未授权异常。

template.render('oauth_example/main.html', {
                "authurl": auth.get_authorization_url(),
                "request_token": auth.request_token
                })

在控制台中我得到:

TweepError: HTTP Error 401: Unauthorized

使用 python 解释器中的库可以正常工作:

导入 tweepy

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)

打印 auth.get_authorization_url()

打印出一个有效的认证 url。但是示例中 MainPage 处理程序开头的相同代码失败了。

class MainPage(RequestHandler):

  def get(self):
    # Build a new oauth handler and display authorization url to user.
    auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
    print auth.get_authorization_url() # EXCEPTION 401 Unauthorized

任何帮助将不胜感激。

【问题讨论】:

    标签: google-app-engine oauth twitter twitter-oauth tweepy


    【解决方案1】:

    找到解决办法

    除了使用回调 URL 更新 tweepy 中的回调之外,还要在 dev.twitter.com 的应用部分更新。

    所以,您必须在

    时提供正确的回调 URL
    auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET, CALLBACK)
    

    还有 twitter 应用部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-10
      • 1970-01-01
      相关资源
      最近更新 更多