def callback(self, request):
        impersonate = request.session.pop(settings.TWITTER_IMPERSONATE_SESSION_KEY, None)
        request_token = request.session.get(REQUEST_TOKEN_FORMAT % self.client.base_url)
        action = request.session.get(ACTION_FORMAT % self.client.base_url)
        view_function = self.view_functions.get(action)
        if not (request_token and view_function):
            raise Exception("OAuth callback was not able to retrieve the needed information from the session.")
        oauth_verifier = request.GET.get('oauth_verifier')
        access_token = self.client.access_token(request_token, verifier=oauth_verifier)
        if not request.user.is_authenticated():
            user = django_authenticate(client=self.client, access_token=access_token, impersonate=impersonate)
            if user:
                django_login(request, user)
        redirect_to = request.session.get('redirect_to') or settings.LOGIN_REDIRECT_URL
        return view_function(request, access_token, redirect_to=redirect_to, impersonate=impersonate)
dataset/ETHPy150Open dgouldin/django-socialite/socialite/apps/base/oauth/decorators.py/OAuthMediator.callback/original