def is_authenticated(account_pk): account = models.RemoteAccount.objects.get(pk=account_pk) if account.has_access(): url = settings.SUPPORT_AUTH_URL auth_header = make_auth_header(account) info = get_ts_info() params = { "version": info.get("version", "Version Missing"), "serial_number": info.get("serialnumber", "Serial Missing"), } try: response = requests.get( url, params=params, headers=auth_header, verify=False ) except requests.exceptions.RequestException as err: logger.error("Request Exception: {0}".format(err)) else: if response.ok: return True else: logger.error("Authentication failure at {0}: {1}".format(url, response)) return False