diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2024-03-09 13:08:11 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-03-29 00:00:15 +0100 |
commit | 1501895d66250679a7fe2a5bd67b368e96965401 (patch) | |
tree | 2c5342097dc987962c829a771530bc15746e0bd5 | |
parent | dcd1536137ec603a2c3db4c10c7688f73c0015b3 (diff) | |
download | wee-slack-1501895d66250679a7fe2a5bd67b368e96965401.tar.gz |
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.
-rw-r--r-- | slack/slack_api.py | 3 | ||||
-rw-r--r-- | slack/slack_workspace.py | 1 |
2 files changed, 3 insertions, 1 deletions
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"]] |