From 1501895d66250679a7fe2a5bd67b368e96965401 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 9 Mar 2024 13:08:11 +0100 Subject: Use enterprise id in edgeapi path if it exists It seems like for enterprise workspaces you have to use the enterprise id (if the token is a workspace level token, `enterprise_id/workspace_id` can also be used, but isn't necessary), while for non-enterprise workspaces the workspace id should be used. --- slack/slack_api.py | 3 ++- slack/slack_workspace.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/slack/slack_api.py b/slack/slack_api.py index 5c6a230..d3e52e4 100644 --- a/slack/slack_api.py +++ b/slack/slack_api.py @@ -73,7 +73,8 @@ class SlackEdgeApi(SlackApiCommon): return self.workspace.token_type == "session" async def _fetch_edgeapi(self, method: str, params: EdgeParams = {}): - url = f"https://edgeapi.slack.com/cache/{self.workspace.id}/{method}" + id_for_path = self.workspace.enterprise_id or self.workspace.id + url = f"https://edgeapi.slack.com/cache/{id_for_path}/{method}" options = self._get_request_options() options["postfields"] = json.dumps(params) options["httpheader"] += "\nContent-Type: application/json" diff --git a/slack/slack_workspace.py b/slack/slack_workspace.py index faa0d73..99bd8aa 100644 --- a/slack/slack_workspace.py +++ b/slack/slack_workspace.py @@ -261,6 +261,7 @@ class SlackWorkspace: async def _connect_oauth(self) -> List[SlackConversation]: rtm_connect = await self.api.fetch_rtm_connect() self.id = rtm_connect["team"]["id"] + self.enterprise_id = rtm_connect["team"].get("enterprise_id") self.domain = rtm_connect["team"]["domain"] self.my_user = await self.users[rtm_connect["self"]["id"]] -- cgit