我正在尝试使用flask在python中使用twitter进行Oauth并且获取请求页面无效

问题描述 投票:0回答:1

我收到以下错误

Whoa there!
The request token for this page is invalid. It may have already been used, or expired because it is too old. Please go back to the site or application that sent you here and try again; it was probably just a mistake

1)以下方法我们将您的Twitter凭证调用到您的Api

2)回调函数是静态的

3)我正在使用Oauth 1并使用谷歌云进行托管

4)我已经清除缓存2次仍然没用

.def _twitter(self):
        # Get the access token supplied
        oauth_token = self.test_credentials.get('oauth_token')
        oauth_token_secret = self.test_credentials.get('oauth_token_secret')
        if not oauth_token or not oauth_token_secret:
            raise AuthenticationException('Invalid request format.', 400)

        auth = tweepy.OAuthHandler(current_app.config['TWITTER_CONSUMER_KEY'], current_app.config['TWITTER_CONSUMER_SECRET'])
        auth.set_access_token(oauth_token, oauth_token_secret)

        api = tweepy.API(auth)
        user = api.verify_credentials()

        if not user:
            raise AuthenticationException('Unable to verify credentials with remote server.', 500)

        # Save the user
        auth_string = self._auth_string(unicode(user.id_str))

        stored_user = User.query(User.auth_ids == auth_string).get()

        if not stored_user:
            return User(name=user.name)

        if stored_user and not stored_user.name:
            stored_user.name = user.name
            stored_user.put()

        return stored_user
python-2.7 twitter oauth google-cloud-platform flash-message
1个回答
1
投票

我忘了在twitter api回调中添加我的回调函数(这些解决了我的错误)

© www.soinside.com 2019 - 2024. All rights reserved.