<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def login(self, username, password, strict=True):
 """ Login as specified user Args: username (str):
 The username to log in with password (str):
 The password for the user strict (bool):
 `True` to thow an error on failure Returns: bool: `True` if successfully logged in; `False` otherwise Raises: :py:func:`mediawiki.exceptions.MediaWikiLoginError`: if \ unable to login Note: Per the MediaWiki API, one should use the `bot password`; \ see https://www.mediawiki.org/wiki/API:Login for more \ information """

        # get login token
        params = {
            "action": "query",
            "meta": "tokens",
            "type": "login",
            "format": "json",
        }
        token_res = self._get_response(params)
        if "query" in token_res and "tokens" in token_res["query"]:
            token = token_res["query"]["tokens"]["logintoken"]

        params = {
            "action": "login",
            "lgname": username,
            "lgpassword": password,
            "lgtoken": token,
            "format": "json",
        }

        res = self._post_response(params)
        if res["login"]["result"] == "Success":
            self._is_logged_in = True
            return True
        self._is_logged_in = False
        reason = res["login"]["reason"]
        if strict:
            msg = "MediaWiki login failure: {}".format(reason)
            raise MediaWikiLoginError(msg)
        return False