diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2024-06-11 16:54:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-11 16:54:13 +0200 |
commit | d6ac24e8759f6f1a7cc816cde274572877286091 (patch) | |
tree | 260ab2ae6d54ab73f107a07803b5d77571764383 /g4f | |
parent | . (diff) | |
parent | Fix har openai access token parsing (diff) | |
download | gpt4free-d6ac24e8759f6f1a7cc816cde274572877286091.tar gpt4free-d6ac24e8759f6f1a7cc816cde274572877286091.tar.gz gpt4free-d6ac24e8759f6f1a7cc816cde274572877286091.tar.bz2 gpt4free-d6ac24e8759f6f1a7cc816cde274572877286091.tar.lz gpt4free-d6ac24e8759f6f1a7cc816cde274572877286091.tar.xz gpt4free-d6ac24e8759f6f1a7cc816cde274572877286091.tar.zst gpt4free-d6ac24e8759f6f1a7cc816cde274572877286091.zip |
Diffstat (limited to 'g4f')
-rw-r--r-- | g4f/Provider/openai/har_file.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/g4f/Provider/openai/har_file.py b/g4f/Provider/openai/har_file.py index 2287d6a6..7644e693 100644 --- a/g4f/Provider/openai/har_file.py +++ b/g4f/Provider/openai/har_file.py @@ -28,7 +28,7 @@ class arkReq: self.userAgent = userAgent arkPreURL = "https://tcr9i.chat.openai.com/fc/gt2/public_key/35536E1E-65B4-4D96-9D97-6ADB7EFF8147" -sessionUrl = "https://chatgpt.com/api/auth/session" +sessionUrl = "https://chatgpt.com/" chatArk: arkReq = None accessToken: str = None cookies: dict = None @@ -68,7 +68,9 @@ def readHAR(): chatArks.append(parseHAREntry(v)) elif v['request']['url'] == sessionUrl: try: - accessToken = json.loads(v["response"]["content"]["text"]).get("accessToken") + match = re.search(r'"accessToken":"(.*?)"', v["response"]["content"]["text"]) + if match: + accessToken = match.group(1) except KeyError: continue cookies = {c['name']: c['value'] for c in v['request']['cookies'] if c['name'] != "oai-did"} |