我正在尝试在Flask上验证Twitter登录。
if flask.request.args.get('oauth_verifier')==None:
twauth = tweepy.OAuthHandler("***","***")
twauth.secure = True
try:
redirect_url = twauth.get_authorization_url() #This call requests the token from twitter and returns to us the authorization URL
except tweepy.TweepError,e:
logging.info('Failed : %s' % e)
print redirect_url
flask.session['request_token'] = twauth.request_token #storing the request token in a session:
twauth.get_authorization_url()
在
2018-06-13 16:50:48.047 JST
Fetching token from https://api.twitter.com/oauth/request_token using client <Client nonce=None, signature_method=HMAC-SHA1, realm=None, encoding=utf-8, timestamp=None, resource_owner_secret=None, decoding=utf-8, verifier=None, signature_type=AUTH_HEADER, rsa_key=None, resource_owner_key=None, client_secret=****, callback_uri=None, client_key=gpQh2S0rWdIdTCHfoaA3q2KYL> (lib.zip/requests_oauthlib/oauth1_session.py:363)
2018-06-13 16:50:48.048 JST
Signing request <PreparedRequest [POST]> using client <Client nonce=None, signature_method=HMAC-SHA1, realm=None, encoding=utf-8, timestamp=None, resource_owner_secret=None, decoding=utf-8, verifier=None, signature_type=AUTH_HEADER, rsa_key=None, resource_owner_key=None, client_secret=****, callback_uri=None, client_key=gpQh2S0rWdIdTCHfoaA3q2KYL> (lib.zip/requests_oauthlib/oauth1_auth.py:63)
2018-06-13 16:50:48.048 JST
Including body in call to sign: False (lib.zip/requests_oauthlib/oauth1_auth.py:75)
2018-06-13 16:50:48.048 JST
Collected params: [(u'oauth_version', u'1.0'), (u'oauth_consumer_key', u'gpQh2S0rWdIdTCHfoaA3q2KYL'), (u'oauth_signature_method', u'HMAC-SHA1'), (u'oauth_nonce', u'25122590467764310441528876248'), (u'oauth_timestamp', u'1528876248')] (lib.zip/oauthlib/oauth1/rfc5849/__init__.py:135)
2018-06-13 16:50:48.049 JST
Normalized params: oauth_consumer_key=gpQh2S0rWdIdTCHfoaA3q2KYL&oauth_nonce=25122590467764310441528876248&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1528876248&oauth_version=1.0 (lib.zip/oauthlib/oauth1/rfc5849/__init__.py:140)
2018-06-13 16:50:48.049 JST
Normalized URI: https://api.twitter.com/oauth/request_token (lib.zip/oauthlib/oauth1/rfc5849/__init__.py:141)
2018-06-13 16:50:48.049 JST
Signing: signature base string: POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_consumer_key%3DgpQh2S0rWdIdTCHfoaA3q2KYL%26oauth_nonce%3D25122590467764310441528876248%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1528876248%26oauth_version%3D1.0 (lib.zip/oauthlib/oauth1/rfc5849/__init__.py:146)
2018-06-13 16:50:48.049 JST
Signature: auihczIZGViCuENQooh5i5BRIA0= (lib.zip/oauthlib/oauth1/rfc5849/__init__.py:153)
2018-06-13 16:50:48.049 JST
Encoding URI, headers and body to utf-8. (lib.zip/oauthlib/oauth1/rfc5849/__init__.py:321)
2018-06-13 16:50:48.049 JST
Updated url: https://api.twitter.com/oauth/request_token (lib.zip/requests_oauthlib/oauth1_auth.py:92)
2018-06-13 16:50:48.050 JST
Updated headers: {'Content-Length': '0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'User-Agent': 'python-requests/2.19.0', 'Connection': 'keep-alive', 'Authorization': 'OAuth oauth_nonce="25122590467764310441528876248", oauth_timestamp="1528876248", oauth_version="1.0", oauth_signature_method="HMAC-SHA1", oauth_consumer_key="gpQh2S0rWdIdTCHfoaA3q2KYL", oauth_signature="auihczIZGViCuENQooh5i5BRIA0%3D"'} (lib.zip/requests_oauthlib/oauth1_auth.py:93)
2018-06-13 16:50:48.050 JST
Updated body: None (lib.zip/requests_oauthlib/oauth1_auth.py:94)
2018-06-13 16:50:48.077 JST
Failed : Only tempfile.TemporaryFile is available for use (/base/data/home/apps/b~ktest321986/20180613t164654.410404564513746141/control/contact.py:68)
我试试localhost,没有问题。 当我部署到GAE时出现问题。 怎么解决这个? 感谢
答案 0 :(得分:0)
我只是发现Tweepy 3.5.0不适用于GAE。 我使用的是2.3.0版本,它可以正常工作。
答案 1 :(得分:0)
我在App Engine中灵活地复制了您的代码,并遇到了相同的部署问题。检查requirements.txt,我指定了Tweepy的旧版本 - 将其更改为最新版本(3.6.0)解决了问题,所以我也会尝试一下。