#NEWLINE# def create_token_response( self , request , token_handler ) : #NEWLINE# #INDENT# 'Return token or error in JSON format.\n\n        If the access token request is valid and authorized, the\n        authorization server issues an access token as described in\n        `Section 5.1`_.  A refresh token SHOULD NOT be included.  If the request\n        failed client authentication or is invalid, the authorization server\n        returns an error response as described in `Section 5.2`_.\n\n        .. _`Section 5.1`: http://tools.ietf.org/html/rfc6749#section-5.1\n        .. _`Section 5.2`: http://tools.ietf.org/html/rfc6749#section-5.2\n        ' #NEWLINE# headers = { #NEWLINE# #INDENT# 'Content-Type' : 'application/json' , #NEWLINE# 'Cache-Control' : 'no-store' , #NEWLINE# 'Pragma' : 'no-cache' , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# log . debug ( 'Validating access token request, %r.' , request ) #NEWLINE# self . validate_token_request ( request ) #NEWLINE# #UNINDENT# except errors . OAuth2Error as e : #NEWLINE# #INDENT# log . debug ( 'Client error in token request. %s.' , e ) #NEWLINE# return ( headers , e . json , e . status_code ) #NEWLINE# #UNINDENT# token = token_handler . create_token ( request , refresh_token = False ) #NEWLINE# log . debug ( 'Issuing token to client id %r (%r), %r.' , request . client_id , request . client , request ) #NEWLINE# return ( headers , json . dumps ( token ) , 200 )