mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-12-24 11:34:02 +03:00
Merge pull request #2054 from RichSteini/main
Fix har openai access token parsing
This commit is contained in:
commit
d6ac24e875
@ -28,7 +28,7 @@ class arkReq:
|
|||||||
self.userAgent = userAgent
|
self.userAgent = userAgent
|
||||||
|
|
||||||
arkPreURL = "https://tcr9i.chat.openai.com/fc/gt2/public_key/35536E1E-65B4-4D96-9D97-6ADB7EFF8147"
|
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
|
chatArk: arkReq = None
|
||||||
accessToken: str = None
|
accessToken: str = None
|
||||||
cookies: dict = None
|
cookies: dict = None
|
||||||
@ -68,7 +68,9 @@ def readHAR():
|
|||||||
chatArks.append(parseHAREntry(v))
|
chatArks.append(parseHAREntry(v))
|
||||||
elif v['request']['url'] == sessionUrl:
|
elif v['request']['url'] == sessionUrl:
|
||||||
try:
|
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:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
cookies = {c['name']: c['value'] for c in v['request']['cookies'] if c['name'] != "oai-did"}
|
cookies = {c['name']: c['value'] for c in v['request']['cookies'] if c['name'] != "oai-did"}
|
||||||
|
Loading…
Reference in New Issue
Block a user