def get_response_check_nonce(self, request): _, oauth_req = initialize_server_request(request) # get_or _create the Nonce object like the authentication # mechanism does. nonce_obj, created = Nonce.objects.get_or_create( consumer_key=token.consumer.key, token_key=token.key, key=oauth_req.get_parameter('oauth_nonce')) # Record calls. recorder.append(created) response = HttpResponse(content='', content_type=b"text/plain; charset=utf-8") handler._WebApplicationHandler__retry.add(response) return response
def delete_oauth_nonce(request): """Delete the OAuth nonce for the given request from the database. This is to allow the exact same request to be retried. """ _, oauth_request = initialize_server_request(request) if oauth_request is not None: try: consumer_key = oauth_request.get_parameter('oauth_consumer_key') token_key = oauth_request.get_parameter('oauth_token') nonce = oauth_request.get_parameter('oauth_nonce') except OAuthError: # Missing OAuth parameter: skip Nonce deletion. pass else: Nonce.objects.filter(consumer_key=consumer_key, token_key=token_key, key=nonce).delete()