File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 11
11
- [ Faster Loading] ( #faster-loading-avoiding-selenium )
12
12
- [ Proxies] ( #proxies )
13
13
- [ Changing model version] ( #changing-claude-model )
14
+ - [ Changing Organization] ( #changing-organization )
14
15
- [ Troubleshooting] ( #troubleshooting )
15
16
- [ Donating] ( #donating )
16
17
@@ -272,6 +273,24 @@ client = ClaudeAPIClient(session, model_name="claude-2.0")
272
273
273
274
You can retrieve the ` model_name ` strings from the [ official API docs] ( https://docs.anthropic.com/claude/docs/models-overview#model-comparison )
274
275
276
+ __________
277
+
278
+ ### Changing Organization
279
+
280
+ As reported in issue [ #23 ] ( https://github.com/st1vms/unofficial-claude-api/issues/23 )
281
+ if you're encountering 403 errors when using Selenium to auto retrieve a ` SessionData ` class and your account has multiple organizations,
282
+ you may want to override the default organization retrieved.
283
+
284
+ By default ` get_session_data ` retrieves the last organization from the result array found [ here] ( https://claude.ai/api/organizations ) .
285
+ You can override the index to fetch by using parameter ` organization_index ` :
286
+
287
+ ``` py
288
+ from claude_api.session import get_session_data
289
+
290
+ # Defaults to -1 (last entry)
291
+ session = get_session_data(organization_index = - 1 )
292
+ ```
293
+
275
294
## TROUBLESHOOTING
276
295
277
296
Some common errors that may arise during the usage of this API:
Original file line number Diff line number Diff line change @@ -38,13 +38,16 @@ class SessionData:
38
38
"""
39
39
40
40
41
- def get_session_data (profile : str = "" , quiet : bool = False ) -> SessionData | None :
41
+ def get_session_data (profile : str = "" , quiet : bool = False , organization_index : int = - 1 ) -> SessionData | None :
42
42
"""
43
43
Retrieves Claude session data
44
44
45
45
This function requires a profile with Claude login and geckodriver installed!
46
46
47
47
The default Firefox profile will be used, if the profile argument was not overwrited.
48
+
49
+ Parameter `organization_index` is by default -1
50
+ (last entry from https://claude.ai/api/organizations)
48
51
"""
49
52
50
53
json_tab_id = 'a[id="rawdata-tab"]'
@@ -81,8 +84,8 @@ def get_session_data(profile: str = "", quiet: bool = False) -> SessionData | No
81
84
if pre .text :
82
85
j = json_loads (pre .text )
83
86
try :
84
- if j and len (j ) >= 1 and "uuid" in j [0 ]:
85
- org_id = j [0 ]["uuid" ]
87
+ if j and len (j ) > organization_index and "uuid" in j [organization_index ]:
88
+ org_id = j [organization_index ]["uuid" ]
86
89
except KeyError :
87
90
print (
88
91
f"\n Unable to retrieve organization_id from profile: { profile } \n "
You can’t perform that action at this time.
0 commit comments