我正在尝试设置此Twitter授权,而无需用户在我们的屏幕中输入引脚但我无法获得正确的设置,我总是被指示输入PIN。尝试使用并关注此包https://github.com/simplegeo/python-oauth2
这是我目前的代码
env = Environment(loader = PackageLoader('buzzient','tmpl'))
template = env.get_template('authtwitter.html')
tmpldict = {}
#SETUP TWITTER AUTHORIZATION OBJECT
consumer_key = '######################'
consumer_secret = '##############################'
request_token_url = 'http://twitter.com/oauth/request_token'
access_token_url = 'http://twitter.com/oauth/access_token'
authorize_url = 'http://twitter.com/oauth/authenticate'
consumer = oauth.Consumer(consumer_key, consumer_secret)
client = oauth.Client(consumer)
#get request token
resp, content = client.request(request_token_url, "GET")
if resp['status'] != '200':
raise Exception("Invalid Response %s." %resp['status'])
request_token = dict(urlparse.parse_qsl(content))
tmpldict['twitauthurl'] = "%s?oauth_token=%s" % ( authorize_url, request_token['oauth_token'] )
qargs=buzzientlib.urlparse_qs(self.request.url,True,False)
t = template.render(tmpldict)
self.response_body = str(t)
该模板只包含指向twitauthurl的链接