def login_and_get_token(self, email, password):  # {{{
        # 0: Check to see if we're already logged in.
        if self.token is not None:
            return

        # 1: Login.
        login_url = 'https://wwws.mint.com/login.event?task=L'
        try:
            self.request_and_check(login_url)
        except __HOLE__:
            raise Exception('Failed to load Mint login page')

        data = {'username': email}
        response = self.post('https://wwws.mint.com/getUserPod.xevent',
                             data=data, headers=self.json_headers).text

        data = {'username': email, 'password': password, 'task': 'L',
                'browser': 'firefox', 'browserVersion': '27', 'os': 'linux'}
        response = self.post('https://wwws.mint.com/loginUserSubmit.xevent',
                             data=data, headers=self.json_headers).text

        if 'token' not in response:
            raise Exception('Mint.com login failed[1]')

        response = json.loads(response)
        if not response['sUser']['token']:
            raise Exception('Mint.com login failed[2]')

        # 2: Grab token.
        self.token = response['sUser']['token']
dataset/ETHPy150Open mrooney/mintapi/mintapi/api.py/Mint.login_and_get_token