当前位置: 首页>>代码示例>>Python>>正文


Python Player.twitter_oauth_token方法代码示例

本文整理汇总了Python中models.Player.twitter_oauth_token方法的典型用法代码示例。如果您正苦于以下问题:Python Player.twitter_oauth_token方法的具体用法?Python Player.twitter_oauth_token怎么用?Python Player.twitter_oauth_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Player的用法示例。


在下文中一共展示了Player.twitter_oauth_token方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: twitter_callback

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import twitter_oauth_token [as 别名]
def twitter_callback(request):
    """ This method deals with the callback needed by twitter, and creating the their user.

    """
    if 'denied' in request.GET:
        return HttpResponseRedirect('/')

    twitter_conn = twitter(
        twitter_token = keys.CONSUMER_KEY,
        twitter_secret = keys.CONSUMER_SECRET,
        oauth_token = request.session['request_token']['oauth_token'],
        oauth_token_secret = request.session['request_token']['oauth_token_secret']
    )

    auth_tokens = twitter_conn.get_authorized_tokens()

    try:
        user = User.objects.get(username = auth_tokens['screen_name'])
    except User.DoesNotExist:
        user = create_django_user(auth_tokens['screen_name'], auth_tokens['oauth_token_secret'])
        player = Player()
        player.user = user
        player.twitter_oauth_token = auth_tokens['oauth_token']
        player.twitter_oauth_secret = auth_tokens['oauth_token_secret']
        request.session['twitter'] = player
        form = PlayerForm(initial={'username': player.user.username})
        return render(request, 'register.html', {'form': form})
    player = Player.objects.get(user=user)
    user = authenticate(username=player.user.username, password=player.twitter_oauth_secret)
    login(request, user)
    return HttpResponseRedirect('/')
开发者ID:fyelles,项目名称:courtside,代码行数:33,代码来源:views.py


注:本文中的models.Player.twitter_oauth_token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。