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 1111 - [ Faster Loading] ( #faster-loading-avoiding-selenium )
1212 - [ Proxies] ( #proxies )
1313 - [ Changing model version] ( #changing-claude-model )
14+ - [ Changing Organization] ( #changing-organization )
1415- [ Troubleshooting] ( #troubleshooting )
1516- [ Donating] ( #donating )
1617
@@ -272,6 +273,24 @@ client = ClaudeAPIClient(session, model_name="claude-2.0")
272273
273274You can retrieve the ` model_name ` strings from the [ official API docs] ( https://docs.anthropic.com/claude/docs/models-overview#model-comparison )
274275
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+
275294## TROUBLESHOOTING
276295
277296Some 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:
3838 """
3939
4040
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 :
4242 """
4343 Retrieves Claude session data
4444
4545 This function requires a profile with Claude login and geckodriver installed!
4646
4747 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)
4851 """
4952
5053 json_tab_id = 'a[id="rawdata-tab"]'
@@ -81,8 +84,8 @@ def get_session_data(profile: str = "", quiet: bool = False) -> SessionData | No
8184 if pre .text :
8285 j = json_loads (pre .text )
8386 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" ]
8689 except KeyError :
8790 print (
8891 f"\n Unable to retrieve organization_id from profile: { profile } \n "
You can’t perform that action at this time.
0 commit comments