<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def credentials_match(self, user_detail, key):
 """Returns True if the key is valid for the user_detail. It will use auth_encoder type the password was encoded with, to check for a key match. :param user_detail: The dict for the user. :param key: The key to validate for the user. :returns: True if the key is valid for the user, False if not. """

        if user_detail:
            creds = user_detail.get('auth')
            try:
                auth_encoder, creds_dict = \
                    swauth.authtypes.validate_creds(creds)
            except ValueError as e:
                self.logger.error('%s' % e.args[0])
                return False
        return user_detail and auth_encoder.match(key, creds, **creds_dict)