

def facebook_callback(request):
    '\n        1. define RequestContext\n        2. access OAuth\n        3. check session\n        4. autheticate token\n        5. raise exception if missing token\n        6. return access callback\n        7. raise exception if mismatch token\n        8. render error \n    '
    ctx = RequestContext(request)
    access = OAuthAccess()
    unauth_token = request.session.get('unauth_token', None)
    try:
        auth_token = access.check_token(unauth_token, request.GET)
    except MissingToken:
        ctx.update({
            'error': 'token_missing',
        })
        logger.error('la_facebook.views.facebook_login: missing token')
    else:
        if auth_token:
            return access.callback(request, access, auth_token)
        else:
            ctx.update({
                'error': 'token_mismatch',
            })
            logger.error('la_facebook.views.facebook_callback: token mismatch, error getting token, or user denied FB login')
    fb_errors = []
    for fb_error_detail in ['error', 'error_description', 'error_reason']:
        if (fb_error_detail in request.GET):
            ctx[('fb_' + fb_error_detail)] = request.GET[fb_error_detail]
            fb_errors.append(request.GET[fb_error_detail])
    logger.warning(('la_facebook.views.facebook_callback: %s' % ', '.join(fb_errors)))
    return render_to_response('la_facebook/fb_error.html', ctx)

dataset/ETHPy150Open pydanny/django-la-facebook/la_facebook/views.py facebook_callback/original