'Return token or error in JSON format.
If the access token request is valid and authorized, the
authorization server issues an access token as described in
`Section 5.1`_.  A refresh token SHOULD NOT be included.  If the request
failed client authentication or is invalid, the authorization server
returns an error response as described in `Section 5.2`_.
.. _`Section 5.1`: http://tools.ietf.org/html/rfc6749#section-5.1
.. _`Section 5.2`: http://tools.ietf.org/html/rfc6749#section-5.2'

def create_token_response(self, request, token_handler):

    headers = {u'Content-Type': u'application/json', u'Cache-Control': u'no-store', u'Pragma': u'no-cache'}
    try:
        log.debug(u'Validating    access    token    request,    %r.', request)
        self.validate_token_request(request)
    except errors.OAuth2Error as e:
        log.debug(u'Client    error    in    token    request.    %s.', e)
        return (headers, e.json, e.status_code)
    token = token_handler.create_token(request, refresh_token=False, save_token=False)
    for modifier in self._token_modifiers:
        token = modifier(token)
    self.request_validator.save_token(token, request)
    log.debug(u'Issuing    token    to    client    id    %r    (%r),    %r.', request.client_id, request.client, token)
    return (headers, json.dumps(token), 200)
