logentries_api/special_alerts.py
def _login(self, username, password):
        """
        ._login() makes three requests:

            * One to the /login/ page to get a CSRF cookie
            * One to /login/ajax/ to get a logged-in session cookie
            * One to /app/ to get the beginning of the account id

        :param username: A valid username (email)
        :type username: str
        :param password: A valid password
        :type password: str
        :return: The account's url id
        :rtype: str
        """

        login_url = 'https://logentries.com/login/'
        login_page_response = self.session.get(url=login_url, headers=self.default_headers)
        if not login_page_response.ok:
            raise ServerException(login_page_response.text)

        login_headers = {
            'Referer': login_url,
            'X-Requested-With': 'XMLHttpRequest',
        }
        login_headers.update(self.default_headers)
        login_response = self.session.post(
            'https://logentries.com/login/ajax/',
            headers=login_headers,
            data=self._get_login_payload(
                username,
                password),
        )
        if not login_response.ok:
            raise ServerException(login_response.text)

        app_response = self.session.get('https://logentries.com/app/', headers=self.default_headers)
        return app_response.url.split('/')[-1]
def _login(self, username, password):
        """
        ._login() makes three requests:

            * One to the /login/ page to get a CSRF cookie
            * One to /login/ajax/ to get a logged-in session cookie
            * One to /app/ to get the beginning of the account id

        :param username: A valid username (email)
        :type username: str
        :param password: A valid password
        :type password: str
        :return: The account's url id
        :rtype: str
        """

        login_url = 'https://logentries.com/login/'
        login_page_response = self.session.get(url=login_url, headers=self.default_headers)
        if not login_page_response.ok:
            raise ServerException(login_page_response.text)

        login_headers = {
            'Referer': login_url,
            'X-Requested-With': 'XMLHttpRequest',
        }
        login_headers.update(self.default_headers)
        login_response = self.session.post(
            'https://logentries.com/login/ajax/',
            headers=login_headers,
            data=self._get_login_payload(
                username,
                password),
        )
        if not login_response.ok:
            raise ServerException(login_response.text)

        app_response = self.session.get('https://logentries.com/app/', headers=self.default_headers)
        return app_response.url.split('/')[-1]
._login() makes three requests:

            * One to the /login/ page to get a CSRF cookie
            * One to /login/ajax/ to get a logged-in session cookie
            * One to /app/ to get the beginning of the account id

        :param username: A valid username (email)
        :type username: str
        :param password: A valid password
        :type password: str
        :return: The account's url id
        :rtype: str