def confirm_authorization_request(self):
        """When consumer confirm the authorization."""
        server = self.server
        scope = request.params.get('scope') or ''
        scopes = scope.split()
        credentials = dict(
            client_id=request.params.get('client_id'),
            redirect_uri=request.params.get('redirect_uri', None),
            response_type=request.params.get('response_type', None),
            state=request.params.get('state', None)
        )
        log.debug('Fetched credentials from request %r.', credentials)
        redirect_uri = credentials.get('redirect_uri')
        log.debug('Found redirect_uri %s.', redirect_uri)

        uri, http_method, body, headers = extract_params(True)
        try:
            ret = server.create_authorization_response(
                uri, http_method, body, headers, scopes, credentials)
            log.debug('Authorization successful.')
            return create_response(*ret)
        except oauth2.FatalClientError as e:
            log.debug('Fatal client error %r', e)
            return redirect(e.in_uri(self.error_uri))
        except oauth2.OAuth2Error as e:
            log.debug('OAuth2Error: %r', e)
            return redirect(e.in_uri(redirect_uri or self.error_uri))
 def decorated(*args, **kwargs):
     server = self.server
     uri, http_method, body, headers = extract_params(True)
     credentials = f(*args, **kwargs) or {}
     log.debug('Fetched extra credentials, %r.', credentials)
     ret = server.create_token_response(
         uri, http_method, body, headers, credentials
     )
     return create_response(*ret)
        def decorated(*args, **kwargs):
            server = self.server

            token = request.params.get('token')
            request.token_type_hint = request.params.get('token_type_hint')
            if token:
                request.token = token

            uri, http_method, body, headers = extract_params(True)
            ret = server.create_revocation_response(
                uri, headers=headers, body=body, http_method=http_method)
            return create_response(*ret)