#NEWLINE# def authenticate_credentials( self , key ) : #NEWLINE# #INDENT# model = self . get_model ( ) #NEWLINE# try : #NEWLINE# #INDENT# token = model . objects . select_related ( 'user' ) . get ( key = token ) #NEWLINE# #UNINDENT# except model . DoesNotExist : #NEWLINE# #INDENT# raise exceptions . AuthenticationFailed ( _ ( 'Invalid token.' ) ) #NEWLINE# #UNINDENT# if ( not token . user . is_active ) : #NEWLINE# #INDENT# raise exceptions . AuthenticationFailed ( _ ( 'User inactive or deleted.' ) ) #NEWLINE# #UNINDENT# return ( token . user , token )