'Retrieve auth tokens from the router.'

def _get_auth_tokens(self):

    _LOGGER.info('Retrieving    auth    tokens...')
    url = 'http://{}/userRpm/LoginRpm.htm?Save=Save'.format(self.host)
    password = hashlib.md5(self.password.encode('utf')[:15]).hexdigest()
    credentials = '{}:{}'.format(self.username, password).encode('utf')
    self.credentials = base64.b64encode(credentials).decode('utf')
    cookie = 'Authorization=Basic    {}'.format(self.credentials)
    response = requests.get(url, headers={'cookie': cookie})
    try:
        result = re.search('window.parent.location.href    =    "https?:\\/\\/.*\\/(.*)\\/userRpm\\/Index.htm";', response.text)
        if (not result):
            return False
        self.token = result.group(1)
        return True
    except ValueError:
        _LOGGER.error("Couldn't    fetch    auth    tokens")
        return False
