Ejemplo n.º 1
0
@login_required
def oauth_authorize_wrapper(request):
    """Wraps the actual oauth user_authorization view, providing for a 
       mechanism for the user to cancel the request."""
    if request.POST:
        if request.POST.get('cancel', False):
            oauth_server, oauth_request = initialize_server_request(request)
            try:
                token = oauth_server.fetch_request_token(oauth_request)
            except OAuthError, err:
                return send_oauth_error(err)
            application = get_object_or_404(OAuthApplication, consumer=token.consumer)
            context = {'oauth_token':token.key, 'application':application}
            return render_to_response('oauth_authorize_denied.html', context_instance=RequestContext(request, context))
    return user_authorization(request)

@login_required
def oauth_authenticate(request, token, callback, params):
    "http://twitter.com/oauth/authenticate?oauth_nonce=90366957&oauth_timestamp=1268517793&oauth_consumer_key=OtbyqgXwg8Xvcx6jWamA&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_token=tEJA3uyAkiNO8PZA0yOnJ3LZGzc5gcgjHkc7Y11Nk&oauth_signature=qhjKRJYRuSlVnj1xW4opbWC67BY%3D"
    "http://127.0.0.1:8081/oauth/authenticate/?oauth_nonce=53622166&oauth_timestamp=1268345627&oauth_consumer_key=x2aV8unHhXj8paGa&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_token=8maV3UKPtZd62VF2&oauth_signature=U4jNhKybUT%2BUN7pNOfDwHJ6%2BdEc%3D"
    #!! application = get_object_or_404(OAuthApplication, )
    context = {}
    context['user'] = request.user
    context['oauth_token'] = token.key
    return HttpResponse('Authenticate view is unimplemented!!')

@login_required
def oauth_connection_list(request):
    context = {'title':'Authorized Applications'}
    tokens = Token.objects.filter(user=request.user)