Пример #1
0
    def login(self) -> bool:
        if self._is_logged():
            return True

        data = {
            "grant_type": "password",
            "username": self._credentials.username,
            "password": self._credentials.password
        }
        response = Request.run(self._token_url, "POST", data,
                               self._header(False), self._auth())
        if response['statusCode'] == 200:
            self._token = response['body']
            self._token['expires_date'] = datetime.fromtimestamp(
                time.mktime(datetime.now().timetuple())) + timedelta(
                    seconds=int(self._token['expires_in']))
            return True
        return False
Пример #2
0
 def _request(self,
              url: str,
              data: dict = None,
              method: str = "GET") -> Dict[str, Any]:
     return Request.run(url, method, data, self._header(), self._auth())