

def twitter_callback(request):
    oauth_token = request.GET['oauth_token']
    oauth_verifier = request.GET['oauth_verifier']
    consumer = oauth.Consumer(settings.KEY, settings.SECRET)
    access_token = oauth.AccessToken(consumer, oauth_token, oauth_verifier)
    user = authenticate(twitter_id=access_token.user_id, username=access_token.username, token=access_token.token, secret=access_token.secret)
    login(request, user)
    redirect_to = request.session['redirect_to']
    if ((not redirect_to) or (not is_safe_redirect(redirect_to))):
        try:
            redirect_to = reverse(settings.LOGIN_REDIRECT_VIEW, args=[user.id])
        except NoReverseMatch:
            redirect_to = settings.LOGIN_REDIRECT_URL
    return HttpResponseRedirect(redirect_to)

dataset/ETHPy150Open mdiep/django-twitter-users/twitter_users/views.py twitter_callback/original