本文整理汇总了Python中twitter.Twitter.exchange_request_token_for_access_token方法的典型用法代码示例。如果您正苦于以下问题:Python Twitter.exchange_request_token_for_access_token方法的具体用法?Python Twitter.exchange_request_token_for_access_token怎么用?Python Twitter.exchange_request_token_for_access_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.Twitter
的用法示例。
在下文中一共展示了Twitter.exchange_request_token_for_access_token方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: auth_return
# 需要导入模块: from twitter import Twitter [as 别名]
# 或者: from twitter.Twitter import exchange_request_token_for_access_token [as 别名]
def auth_return(request):
"""Get the access token back from Twitter and load user info"""
auth_broken_msg = _(u"Authentication with Twitter went wrong."
u" <a href=\"/\">Start over</a>.")
unauthed_token = request.session.get("unauthed_token", None)
if not unauthed_token:
return fail(request, auth_broken_msg)
token = OAuthToken.from_string(unauthed_token)
if token.key != request.GET.get("oauth_token", "no-token"):
return fail(request, auth_broken_msg)
tw = Twitter()
access_token = tw.exchange_request_token_for_access_token(token)
request.session["access_token"] = access_token.to_string()
u = tw.verify_credentials()
log.info(u"%s logged in, following %s" % (u["screen_name"],
u["friends_count"]))
request.session["screen_name"] = u["screen_name"]
return HttpResponseRedirect(reverse("home"))