# Path: pogom/pgoapi/utilities.py
# def get_time(ms=False):
#     if ms:
#         return int(time.time() * 1000)
#     else:
#         return int(time.time())


from future.standard_library import install_aliases
from urllib.parse import parse_qs
from .auth import Auth
from .utilities import get_time
from .exceptions import AuthException
import re
import six
import json
import logging
import requests
            self.log.debug('Using cached PTC Access Token')
            return self._access_token
        else:
            if force_refresh:
                self.log.info('Forced request of PTC Access Token!')
            else:
                self.log.info('Request PTC Access Token...')

            data1 = {
                'client_id': 'mobile-app_pokemon-go',
                'redirect_uri': 'https://www.nianticlabs.com/pokemongo/error',
                'client_secret': self.PTC_LOGIN_CLIENT_SECRET,
                'grant_type': 'refresh_token',
                'code': self._refresh_token,
            }

            try:
                r2 = self._session.post(self.PTC_LOGIN_OAUTH, data=data1, timeout=10)
            except Exception as e:
                self.log.error('PTC Login failed.')
                self.log.debug('PTC Login fail: {}'.format(e))
                return False

            qs = r2.content.decode('utf-8')
            token_data = parse_qs(qs)

            access_token = token_data.get('access_token', None)
            if access_token is not None:
                self._access_token = access_token[0]


# Path: pogom/pgoapi/utilities.py
# def get_time(ms=False):
#     if ms:
#         return int(time.time() * 1000)
#     else:
#         return int(time.time())


# Path: pogom/pgoapi/auth_ptc.py
from future.standard_library import install_aliases
from urllib.parse import parse_qs
from .auth import Auth
from .utilities import get_time
from .exceptions import AuthException
import re
import six
import json
import logging
import requests

            self.log.debug('Using cached PTC Access Token')
            return self._access_token
        else:
            if force_refresh:
                self.log.info('Forced request of PTC Access Token!')
            else:
                self.log.info('Request PTC Access Token...')

            data1 = {
                'client_id': 'mobile-app_pokemon-go',
                'redirect_uri': 'https://www.nianticlabs.com/pokemongo/error',
                'client_secret': self.PTC_LOGIN_CLIENT_SECRET,
                'grant_type': 'refresh_token',
                'code': self._refresh_token,
            }

            try:
                r2 = self._session.post(self.PTC_LOGIN_OAUTH, data=data1, timeout=10)
            except Exception as e:
                self.log.error('PTC Login failed.')
                self.log.debug('PTC Login fail: {}'.format(e))
                return False

            qs = r2.content.decode('utf-8')
            token_data = parse_qs(qs)

            access_token = token_data.get('access_token', None)
            if access_token is not None:
                self._access_token = access_token[0]


                now_s = get_time()