<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def authenticate(self, username, password):
 """Authenticate against the ObjectRocket API. :param str username: The username to perform basic authentication against the API with. :param str password: The password to perform basic authentication against the API with. :returns: A token used for authentication against token protected resources. :rtype: str """

        # Update the username and password bound to this instance for re-authentication needs.
        self._username = username
        self._password = password

        # Attempt to authenticate.
        resp = requests.get(
            self._url,
            auth=(username, password),
            **self._default_request_kwargs
        )

        # Attempt to extract authentication data.
        try:
            if resp.status_code == 200:
                json_data = resp.json()
                token = json_data['data']['token']
            elif resp.status_code == 401:
                raise errors.AuthFailure(resp.json().get('message', 'Authentication Failure.'))
            else:
                raise errors.AuthFailure(
                    "Unknown exception while authenticating: '{}'".format(resp.text)
                )
        except errors.AuthFailure:
            raise
        except Exception as ex:
            logging.exception(ex)
            raise errors.AuthFailure('{}: {}'.format(ex.__class__.__name__, ex))

        # Update the token bound to this instance for use by other client operations layers.
        self._token = token
        logger.info('New API token received: "{}".'.format(token))
        return token