'Place token according to response mode.
Base classes can define a default response mode for their authorization
response by overriding the static `default_response_mode` member.'

def prepare_authorization_response(self, request, token, headers, body, status):

    request.response_mode = (request.response_mode or self.default_response_mode)
    if (request.response_mode not in (u'query', u'fragment')):
        log.debug(u'Overriding    invalid    response    mode    %s    with    %s', request.response_mode, self.default_response_mode)
        request.response_mode = self.default_response_mode
    token_items = token.items()
    if (request.response_type == u'none'):
        state = token.get(u'state', None)
        if state:
            token_items = [(u'state', state)]
        else:
            token_items = []
    if (request.response_mode == u'query'):
        headers[u'Location'] = add_params_to_uri(request.redirect_uri, token_items, fragment=False)
        return (headers, body, status)
    if (request.response_mode == u'fragment'):
        headers[u'Location'] = add_params_to_uri(request.redirect_uri, token_items, fragment=True)
        return (headers, body, status)
    raise NotImplementedError(u'Subclasses    must    set    a    valid    default_response_mode')
