def oauth_auth_view(request, token, callback, params): form = forms.OAuthAuthenticationForm(initial={ 'oauth_token': token.key, 'oauth_callback': callback, }) return render_to_response('piston/authorize_token.html', {'form': form}, RequestContext(request))
def oauth_auth_view(request, token, callback, params): form = forms.OAuthAuthenticationForm(initial={ 'oauth_token': token.key, 'oauth_callback': token.get_callback_url() or callback, }) context = dict(form=form, token=token) return render_to_response('piston/authorize_token.html', context, RequestContext(request))
def oauth_auth_view(request, token, callback, params): print "Auth view" form = forms.OAuthAuthenticationForm( initial={ 'oauth_token': token.key, 'oauth_callback': token.get_callback_url() or callback, }) return render_to_response('api/oauth/authorize_token.html', { 'form': form, }, RequestContext(request))
def oauth_auth_view(request, token, callback, params): form = forms.OAuthAuthenticationForm( initial={ "oauth_token": token.key, "oauth_callback": token.get_callback_url() or callback, } ) return render_to_response( "piston/authorize_token.html", {"form": form}, RequestContext(request) )
def oauth_auth(request, token, callback, params): form = forms.OAuthAuthenticationForm( initial={ 'oauth_token': token.key, 'authorize_access': True, 'oauth_callback': token.get_callback_url() or callback, }) return direct_to_template(request, 'piston/authorize_token.html', { 'form': form, 'token': token })
def oauth_user_auth(request): oauth_server, oauth_request = initialize_server_request(request) if oauth_request is None: return INVALID_PARAMS_RESPONSE try: token = oauth_server.fetch_request_token(oauth_request) except oauth.OAuthError as err: return send_oauth_error(err) try: callback = oauth_server.get_callback(oauth_request) except: callback = None if request.method == "GET": params = oauth_request.get_normalized_parameters() oauth_view = getattr(settings, 'OAUTH_AUTH_VIEW', None) if oauth_view is None: return oauth_auth_view(request, token, callback, params) else: return get_callable(oauth_view)(request, token, callback, params) elif request.method == "POST": try: form = forms.OAuthAuthenticationForm(request.POST) if form.is_valid(): token = oauth_server.authorize_token(token, request.user) args = '?' + token.to_string(only_key=True) else: args = '?error=%s' % 'Access not granted by user.' print("FORM ERROR", form.errors) if not callback: callback = getattr(settings, 'OAUTH_CALLBACK_VIEW') return get_callable(callback)(request, token) response = HttpResponseRedirect(callback + args) except oauth.OAuthError as err: response = send_oauth_error(err) else: response = HttpResponse('Action not allowed.') return response
def oauth_auth_view(request, token, callback, params): """ This shows the: "Do you want to authorize X on Y?" message It contains the token and callback (next url). It is called by: piston.authentication.oauth_user_auth, and it doesn't have an associated URL. """ form = forms.OAuthAuthenticationForm(initial={ 'oauth_token': token.key, 'oauth_callback': token.get_callback_url() or callback, }) consumer_key = request.GET.get('oauth_consumer_key', '') consumer = Consumer.objects.get(key=consumer_key) return render_to_response('piston/authorize_token.html', { 'form': form, 'consumer': consumer }, RequestContext(request))
try: callback = oauth_server.get_callback(oauth_request) except: callback = None if request.method == "GET": params = oauth_request.get_normalized_parameters() oauth_view = getattr(settings, 'OAUTH_AUTH_VIEW', None) if oauth_view is None: return oauth_auth_view(request, token, callback, params) else: return get_callable(oauth_view)(request, token, callback, params) elif request.method == "POST": try: form = forms.OAuthAuthenticationForm(request.POST) if form.is_valid(): token = oauth_server.authorize_token(token, request.user) args = '?' + token.to_string(only_key=True) else: args = '?error=%s' % 'Access not granted by user.' print "FORM ERROR", form.errors if not callback: callback = getattr(settings, 'OAUTH_CALLBACK_VIEW') return get_callable(callback)(request, token) response = HttpResponseRedirect(callback + args) except oauth.OAuthError, err: response = send_oauth_error(err)