问题
app_key=" "
app_secret=" "
twitter = Twython(app_key=app_key,
app_secret=app_secret)
auth_props = twitter.get_authentication_tokens()
oauth_token = auth_props['oauth_token']
oauth_token_secret = auth_props['auth_url']
print 'Connect to Twitter via: %s' % auth_props['auth_url']
print twitter.search(q='python')
I have the above twython code and the authentication is not working.
I am getting,
TwythonAuthError: Twitter API returned a 400 (Bad Request), Bad Authentication data at print twitter.search(q='python')
Do I need a callback url? I am just starting a project, I do not have a dedicated website for it.
回答1:
I am a collaborator on the Twython project.
Please follow these steps:
- https://github.com/ryanmcgrath/twython#authorization-url
- https://github.com/ryanmcgrath/twython#handling-the-callback
Save your oauth token and secret
then try
app_key = 'YOUR_APP_KEY'
app_secret = 'YOUR_APP_SECRET'
oauth_token = auth_tokens['oauth_token'] # from step 2
oauth_token_secret = auth_tokens['oauth_token_secret'] # from step 2
t = Twython(app_key, app_secret, oauth_token, oauth_token_secret)
t.search(q='python')
来源:https://stackoverflow.com/questions/16866323/authentication-with-twython