summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/openai/har_file.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-11-21 08:24:29 +0100
committerGitHub <noreply@github.com>2024-11-21 08:24:29 +0100
commit4be8e69ea242ea452113bcb3a2596a4959bb3425 (patch)
treea6ffcf616474d55ce97d578612bdfafde17eff1c /g4f/Provider/openai/har_file.py
parentMerge pull request #2395 from hlohaus/open (diff)
parentImprove reading .har file in OpenaiChat (diff)
downloadgpt4free-4be8e69ea242ea452113bcb3a2596a4959bb3425.tar
gpt4free-4be8e69ea242ea452113bcb3a2596a4959bb3425.tar.gz
gpt4free-4be8e69ea242ea452113bcb3a2596a4959bb3425.tar.bz2
gpt4free-4be8e69ea242ea452113bcb3a2596a4959bb3425.tar.lz
gpt4free-4be8e69ea242ea452113bcb3a2596a4959bb3425.tar.xz
gpt4free-4be8e69ea242ea452113bcb3a2596a4959bb3425.tar.zst
gpt4free-4be8e69ea242ea452113bcb3a2596a4959bb3425.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/openai/har_file.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/g4f/Provider/openai/har_file.py b/g4f/Provider/openai/har_file.py
index d731bf73..2c7c1604 100644
--- a/g4f/Provider/openai/har_file.py
+++ b/g4f/Provider/openai/har_file.py
@@ -63,26 +63,28 @@ def readHAR():
continue
for v in harFile['log']['entries']:
v_headers = get_headers(v)
- try:
- if "openai-sentinel-proof-token" in v_headers:
- RequestConfig.proof_token = json.loads(base64.b64decode(
- v_headers["openai-sentinel-proof-token"].split("gAAAAAB", 1)[-1].encode()
- ).decode())
- if "openai-sentinel-turnstile-token" in v_headers:
- RequestConfig.turnstile_token = v_headers["openai-sentinel-turnstile-token"]
- except Exception as e:
- debug.log(f"Read proof token: {e}")
if arkose_url == v['request']['url']:
RequestConfig.arkose_request = parseHAREntry(v)
- elif v['request']['url'] == start_url or v['request']['url'].startswith(conversation_url):
+ elif v['request']['url'].startswith(start_url):
try:
match = re.search(r'"accessToken":"(.*?)"', v["response"]["content"]["text"])
if match:
RequestConfig.access_token = match.group(1)
except KeyError:
- continue
- RequestConfig.cookies = {c['name']: c['value'] for c in v['request']['cookies']}
- RequestConfig.headers = v_headers
+ pass
+ try:
+ if "openai-sentinel-proof-token" in v_headers:
+ RequestConfig.headers = v_headers
+ RequestConfig.proof_token = json.loads(base64.b64decode(
+ v_headers["openai-sentinel-proof-token"].split("gAAAAAB", 1)[-1].encode()
+ ).decode())
+ if "openai-sentinel-turnstile-token" in v_headers:
+ RequestConfig.turnstile_token = v_headers["openai-sentinel-turnstile-token"]
+ if "authorization" in v_headers:
+ RequestConfig.access_token = v_headers["authorization"].split(" ")[1]
+ RequestConfig.cookies = {c['name']: c['value'] for c in v['request']['cookies']}
+ except Exception as e:
+ debug.log(f"Error on read headers: {e}")
if RequestConfig.proof_token is None:
raise NoValidHarFileError("No proof_token found in .har files")