#NEWLINE# def validate_token_request( self , request ) : #NEWLINE# #INDENT# if ( not getattr ( request , 'grant_type' , None ) ) : #NEWLINE# #INDENT# raise errors . InvalidRequestError ( 'Request is missing grant type.' , request = request ) #NEWLINE# #UNINDENT# if ( not ( request . grant_type == 'client_credentials' ) ) : #NEWLINE# #INDENT# raise errors . UnsupportedGrantTypeError ( request = request ) #NEWLINE# #UNINDENT# for param in ( 'grant_type' , 'scope' ) : #NEWLINE# #INDENT# if ( param in request . duplicate_params ) : #NEWLINE# #INDENT# raise errors . InvalidRequestError ( description = ( 'Duplicate %s parameter.' % param ) , request = request ) #NEWLINE# #UNINDENT# #UNINDENT# log . debug ( 'Authenticating client, %r.' , request ) #NEWLINE# if ( not self . request_validator . authenticate_client ( request ) ) : #NEWLINE# #INDENT# log . debug ( 'Client authentication failed, %r.' , request ) #NEWLINE# raise errors . InvalidClientError ( request = request ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not hasattr ( request . client , 'client_id' ) ) : #NEWLINE# #INDENT# raise NotImplementedError ( 'Authenticate client must set the request.client.client_id attribute in authenticate_client.' ) #NEWLINE# #UNINDENT# #UNINDENT# self . validate_grant_type ( request ) #NEWLINE# log . debug ( 'Authorizing access to user %r.' , request . user ) #NEWLINE# request . client_id = ( request . client_id or request . client . client_id ) #NEWLINE# self . validate_scopes ( request )