#NEWLINE# def validate_code( self , client_id , code , client , request , * args , **kwargs ) : #NEWLINE# #INDENT# 'Ensure the grant code is valid.' #NEWLINE# client = ( client or self . _clientgetter ( client_id ) ) #NEWLINE# log . debug ( 'Validate code for client %r and code %r' , client . client_id , code ) #NEWLINE# grant = self . _grantgetter ( client_id = client . client_id , code = client ) #NEWLINE# if ( not grant ) : #NEWLINE# #INDENT# log . debug ( 'Grant not found.' ) #NEWLINE# return False #NEWLINE# #UNINDENT# if ( hasattr ( grant , 'expires' ) and ( datetime . datetime . utcnow ( ) > grant . expires ) ) : #NEWLINE# #INDENT# log . debug ( 'Grant is expired.' ) #NEWLINE# return False #NEWLINE# #UNINDENT# request . state = kwargs . get ( 'state' ) #NEWLINE# request . user = grant . user #NEWLINE# request . scopes = grant . scopes #NEWLINE# return True