예제 #1
0
 def wrapped(request, *args, **kwargs):
     dropbox_user = DropboxUser.objects.get_or_none(user=request.user)
     if dropbox_user and dropbox_user.access_token:
         return view_func(request, *args, **kwargs)
     if not dropbox_user or not dropbox_user.access_token:
         flow = get_auth_flow(request)
         auth_url = flow.start()
         return HttpResponseRedirect(auth_url)
예제 #2
0
 def wrapped(request, *args, **kwargs):
     dropbox_user = DropboxUser.objects.get_or_none(user=request.user)
     if dropbox_user and dropbox_user.access_token:
         return view_func(request, *args, **kwargs)
     if not dropbox_user or not dropbox_user.access_token:
         flow = get_auth_flow(request)
         auth_url = flow.start()
         return HttpResponseRedirect(auth_url)
예제 #3
0
def auth(request):
    try:
        flow = get_auth_flow(request)
        access_token, user_id, url_state = flow.finish(request.GET)
    except dropbox.oauth.BadRequestException:
        return HttpResponseBadRequest()
    except dropbox.oauth.BadStateException:
        # Start the auth flow again.
        return connect(request)
    except dropbox.oauth.CsrfException:
        return HttpResponseForbidden()
    except dropbox.oauth.NotApprovedException:
        messages.warning(request, 'Dropbox authentication was not approved.')
        return HttpResponseRedirect(reverse('dashboard'))
    except dropbox.oauth.ProviderException as err:
        logger.exception('Error authenticating Dropbox', err)
        return HttpResponseForbidden()
    dropbox_user, created = DropboxUser.objects.update_or_create(
        user=request.user, defaults={'access_token': access_token})
    messages.success(request, 'Dropbox authentication successful.')
    return HttpResponseRedirect(reverse('dashboard'))
예제 #4
0
def auth(request):
    try:
        flow = get_auth_flow(request)
        access_token, user_id, url_state = flow.finish(request.GET)
    except DropboxOAuth2Flow.BadRequestException:
        return HttpResponseBadRequest()
    except DropboxOAuth2Flow.BadStateException:
        # Start the auth flow again.
        return connect(request)
    except DropboxOAuth2Flow.CsrfException:
        return HttpResponseForbidden()
    except DropboxOAuth2Flow.NotApprovedException:
        messages.warning(request, 'Dropbox authentication was not approved.')
        return HttpResponseRedirect(reverse('dashboard'))
    except DropboxOAuth2Flow.ProviderException as err:
        logger.exception('Error authenticating Dropbox', err)
        return HttpResponseForbidden()
    dropbox_user, created = DropboxUser.objects.update_or_create(
        user=request.user,
        defaults={'access_token': access_token}
    )
    messages.success(request, 'Dropbox authentication successful.')
    return HttpResponseRedirect(reverse('dashboard'))
예제 #5
0
def connect(request):
    flow = get_auth_flow(request)
    auth_url = flow.start()
    return HttpResponseRedirect(auth_url)
예제 #6
0
def connect(request):
    flow = get_auth_flow(request)
    auth_url = flow.start()
    return HttpResponseRedirect(auth_url)