Open kqvanity opened 4 hours ago
@kqvanity Can you please post the result of visiting https://claude.ai/api/organizations through logged Firefox profile? Maybe it is related to your default organization being unavailable, and this could be a duplicate of #23, just to check...
As I see it, get_session_data
failed to parse the organization uuid from that endpoint...And as a result it returned None
which throwed the exception on ClaudeAPIClient
. This usually means the json returned from /api/organizations
was invalid...
post the result of visiting
[
{
"id": 14182401,
"uuid": "552779e3-b45a-4d48-9e05-6d152ca782ea",
"name": "Github",
"settings": {
"claude_console_privacy": "default_private",
"allowed_invite_domains": null
},
"capabilities": [
"api"
],
"rate_limit_tier": "auto_api_evaluation",
"billing_type": null,
"free_credits_status": null,
"data_retention": "default",
"api_disabled_reason": "out_of_credits",
"api_disabled_until": null,
"billable_usage_paused_until": null,
"raven_type": null,
"created_at": "2024-06-21T17:03:47.830914Z",
"updated_at": "2024-06-21T17:03:47.830914Z",
"active_flags": []
},
{
"id": 23162662,
"uuid": "3675554f-5b05-4f44-881f-b66e28869268",
"name": "solicitmind@gmail.com's Organization",
"settings": {
"claude_console_privacy": "default_private",
"allowed_invite_domains": null
},
"capabilities": [
"chat"
],
"rate_limit_tier": "default_claude_ai",
"billing_type": null,
"free_credits_status": null,
"data_retention": "default",
"api_disabled_reason": null,
"api_disabled_until": null,
"billable_usage_paused_until": null,
"raven_type": null,
"created_at": "2024-09-29T09:24:20.496864Z",
"updated_at": "2024-09-29T09:24:20.496864Z",
"active_flags": []
}
]
could be duplicate of
I did check it out before, but knowing that the 'solution' got merged, I thought that ought to be a different error
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?
It seems you do also have the last organization set with capabilities chat
.
I guess using get_session_data(organization_index=1)
(or with 0) wouldn't change much of a thing tho...as the intended behaviour should look for the last entry in that json...but still it can't find the uuid in there...
I would need to inspect the json retrieved here https://github.com/st1vms/unofficial-claude-api/blob/6447d833b1c3a8304638d36a48ff50b49821aa6d/claude_api/session.py#L85
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: https://github.com/st1vms/unofficial-claude-api/blob/6447d833b1c3a8304638d36a48ff50b49821aa6d/claude_api/session.py#L63
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 nvim venv/lib/python3.12/site-packages/claude_api/session.py
, but no changes are visible!
@st1vms I keep changing those lines at the the virtual environment's dir at
nvim venv/lib/python3.12/site-packages/claude_api/session.py
, but no changes are visible!
I suggest you try outside virtual environment, by installing from source using
pip install -e .
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
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