-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to retrieve organization_id | create_chat request error #27
Comments
@kqvanity Can you please post the result of visiting https://claude.ai/api/organizations through logged Firefox profile? As I see it, |
I did check it out before, but knowing that the 'solution' got merged, I thought that ought to be a different error |
Did you retrieved this with the profile that's causing errors? I guess using
If you could install this library from source and print the json on that line when the error occurs it would be very useful. |
You can also inspect if selenium starts with a logged profile by turning off headless mode in this line:
My first assumption would be that the profile is not logged... |
@st1vms I keep changing those lines at the the virtual environment's dir at |
I suggest you try outside virtual environment, by installing from source using
with a terminal inside the source dir. |
sorry. I had to let the script auto fetch the credentials with selenium for it to pick the changes I've made (instead of hardcoding them). Here's the output. python3 unofficial-claude.py
Retrieving Claude session cookie from /home/keinvanity/.mozilla/firefox/gmpc627g.default-release
pre {"type":"error","error":{"type":"permission_error","message":"Invalid authorization"}}
j {'type': 'error', 'error': {'type': 'permission_error', 'message': 'Invalid authorization'}}
Unable to retrieve organization_id from profile: /home/keinvanity/.mozilla/firefox/gmpc627g.default-release
Check if this profile is logged into Claude!
Traceback (most recent call last):
File "/home/keinvanity/Downloads/claude-misc/unofficial-claude-dir/unofficial-claude.py", line 33, in <module>
client = ClaudeAPIClient(session, model_name='claude-3-5-sonnet-20240620', timeout=240)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/keinvanity/Downloads/claude-misc/unofficial-claude-dir/venv/lib/python3.12/site-packages/claude_api/client.py", line 147, in __init__
raise ValueError("Invalid SessionData argument!")
ValueError: Invalid SessionData argument!
It's also worth mentioning that selenium opens up firefox with old extensions of mine still being present! I can't persist firefox to inspect it. |
Selenium basically loads another profile that doesn't have claude logged in. I don't know how to set which Firefox profile to load |
Does it work when not giving any profile to get_session_data ? Apart from double checking the profile path... |
I already tried to pass the values right away. I visited
|
I'm sorry but I can't recreate the issue on my end. Can you please take a look at the response in unofficial-claude-api/claude_api/client.py Line 338 in 6447d83
|
That's the change I've made print(payload)
print(headers)
response = http_post(
url,
headers=headers,
data=payload,
proxies=self.__get_proxy(),
timeout=self.timeout,
impersonate="chrome110",
)
print(response.text)
if response and response.status_code == 201:
j = response.json()
if j and "uuid" in j:
return j["uuid"]
return None and that's the output {"name":"","uuid":"ae0cc...............-719249bfd0a4"}
{'Host': 'claude.ai', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36', 'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate, br', 'Content-Type': 'application/json', 'Content-Length': '57', 'Referer': 'https://claude.ai/chats', 'Origin': 'https://claude.ai', 'DNT': '1', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'Connection': 'keep-alive', 'Cookie': 'CH-prefers-color-scheme=light; __ssid=a5addfdf8.......f8e1438aa80; lastActiveOrg=3675554f-5b.......-b66e28869268; activitySessionId=02850caa-ec.............8a-297805bbbccd; __stripe_mid=cad07f96-fc54-4c73-89b0-e2f239331fac1ff7ad; sessionKey=sk-ant-sid01...................27A', 'TE': 'trailers'}
{"type":"error","error":{"type":"invalid_request_error","message":"Input should be a valid dictionary o
Message limit hit, cannot create chat... |
The error indicates a problem with the payload, but I can not recreate the bug on my end. Maybe try with another account and see if it works. I doubt they changed that endpoint... |
I'll try to avoid selenium altogether. The organization ID i pass is the second UUID retrieved from cookie_header_value = "CH-prefers-color-scheme=light; __ssid=a5addf..............7df8e1438aa80; lastActiveOrg=36.....-.......869268; __stripe_mid=cad07f96.....-........-....9331fac1ff7ad; sessionKey=sk-ant-sid01-wI.....................3PTgWxkSk3FpeQ-jIqAeAAA; activitySessionId=3a......5-0183-4ad9-9ccc.........uoM9ywZODlIGvbF...............UQ6fIkpHU.8WsBYu16KsdMA7VCn72_TWC_jr4xd3E.XPlCl7CYjJ5vsLig9.mM90vfP7bbVs9TJB1x12lOaa.QhA"
user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0"
# You can retrieve this string from /api/organizations endpoint
# If omitted or None it will be auto retrieved when instantiating ClaudeAPIClient
organization_id = "3675........-......68"
session: SessionData = SessionData(cookie_header_value, user_agent, organization_id) |
when I try to automatically login using selenium, i get the following error (I have two profile at firefox btw, and I sign claude into both of them)
when omitting selenium, and provide the organization id, and session key manually, I get this error instead
The text was updated successfully, but these errors were encountered: