示例#1
0
文件: rpc_api.py 项目: Eth4nZ/pgoapi
    def request(self, endpoint, subrequests, player_position):

        if not self._auth_provider or self._auth_provider.is_login() is False:
            raise NotLoggedInException()

        request_proto = self._build_main_request(subrequests, player_position)
        response = self._make_rpc(endpoint, request_proto)

        response_dict = self._parse_main_response(response, subrequests)

        if ('auth_ticket' in response_dict) and ('expire_timestamp_ms' in response_dict['auth_ticket']) and (self._auth_provider.is_new_ticket(response_dict['auth_ticket']['expire_timestamp_ms'])):
            had_ticket = self._auth_provider.has_ticket()

            auth_ticket = response_dict['auth_ticket']
            self._auth_provider.set_ticket(
                [auth_ticket['expire_timestamp_ms'], base64.standard_b64decode(auth_ticket['start']), base64.standard_b64decode(auth_ticket['end'])])

            now_ms = get_time_ms()
            h, m, s = get_format_time_diff(now_ms, auth_ticket['expire_timestamp_ms'], True)

            if had_ticket:
                self.log.debug('Replacing old auth ticket with new one valid for %02d:%02d:%02d hours (%s < %s)', h, m, s, now_ms, auth_ticket['expire_timestamp_ms'])
            else:
                self.log.debug('Received auth ticket valid for %02d:%02d:%02d hours (%s < %s)', h, m, s, now_ms, auth_ticket['expire_timestamp_ms'])

        if isinstance(response_dict, dict) and 'status_code' in response_dict:
            sc = response_dict['status_code']
            if sc == 102:
                raise NotLoggedInException()
            elif sc == 52:
                raise ServerSideRequestThrottlingException("Request throttled by server... slow down man")

        return response_dict
示例#2
0
 def check_ticket(self):
     if self.has_ticket():
         now_ms = get_time_ms()
         if now_ms < (self._ticket_expire - 10000):
             h, m, s = get_format_time_diff(now_ms, self._ticket_expire, True)
             self.log.debug('Auth ticket still valid for further %02d:%02d:%02d hours (%s < %s)', h, m, s, now_ms, self._ticket_expire)
             return True
         else:
             self.log.debug('Removed expired auth ticket (%s < %s)', now_ms, self._ticket_expire)
             self._ticket_expire, self._ticket_start, self._ticket_end = (None, None, None)
             return False
     else:
         return False
示例#3
0
文件: rpc_api.py 项目: rnadna1/fsd
    def check_authentication(self, response_dict):
        if isinstance(response_dict, dict) and ('auth_ticket' in response_dict) and \
           ('expire_timestamp_ms' in response_dict['auth_ticket']) and \
           (self._auth_provider.is_new_ticket(response_dict['auth_ticket']['expire_timestamp_ms'])):

            had_ticket = self._auth_provider.has_ticket()

            auth_ticket = response_dict['auth_ticket']
            self._auth_provider.set_ticket(
                [auth_ticket['expire_timestamp_ms'], base64.standard_b64decode(auth_ticket['start']), base64.standard_b64decode(auth_ticket['end'])])

            now_ms = get_time_ms()
            h, m, s = get_format_time_diff(now_ms, auth_ticket['expire_timestamp_ms'], True)

            if had_ticket:
                self.log.debug('Replacing old auth ticket with new one valid for %02d:%02d:%02d hours (%s < %s)', h, m, s, now_ms, auth_ticket['expire_timestamp_ms'])
            else:
                self.log.debug('Received auth ticket valid for %02d:%02d:%02d hours (%s < %s)', h, m, s, now_ms, auth_ticket['expire_timestamp_ms'])
示例#4
0
    def check_authentication(self, response_dict):
        if isinstance(response_dict, dict) and ('auth_ticket' in response_dict) and \
           ('expire_timestamp_ms' in response_dict['auth_ticket']) and \
           (self._auth_provider.is_new_ticket(response_dict['auth_ticket']['expire_timestamp_ms'])):

            had_ticket = self._auth_provider.has_ticket()

            auth_ticket = response_dict['auth_ticket']
            self._auth_provider.set_ticket(
                [auth_ticket['expire_timestamp_ms'], base64.standard_b64decode(auth_ticket['start']), base64.standard_b64decode(auth_ticket['end'])])

            now_ms = get_time_ms()
            h, m, s = get_format_time_diff(now_ms, auth_ticket['expire_timestamp_ms'], True)

            if had_ticket:
                self.log.debug('Replacing old auth ticket with new one valid for %02d:%02d:%02d hours (%s < %s)', h, m, s, now_ms, auth_ticket['expire_timestamp_ms'])
            else:
                self.log.debug('Received auth ticket valid for %02d:%02d:%02d hours (%s < %s)', h, m, s, now_ms, auth_ticket['expire_timestamp_ms'])
示例#5
0
 def check_ticket(self):
     if self.has_ticket():
         now_ms = get_time_ms()
         if now_ms < (self._ticket_expire - 10000):
             h, m, s = get_format_time_diff(now_ms, self._ticket_expire,
                                            True)
             self.log.debug(
                 'Auth ticket still valid for further %02d:%02d:%02d hours (%s < %s)',
                 h, m, s, now_ms, self._ticket_expire)
             return True
         else:
             self.log.debug('Removed expired auth ticket (%s < %s)', now_ms,
                            self._ticket_expire)
             self._ticket_expire, self._ticket_start, self._ticket_end = (
                 None, None, None)
             return False
     else:
         return False