Skip to content

Commit 16d2908

Browse files
committed
Fix #208 by updating AsyncOAuthFlow
1 parent a11f6d1 commit 16d2908

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

slack_bolt/oauth/async_oauth_flow.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ async def run_installation(self, code: str) -> Optional[Installation]:
308308
installed_enterprise: Dict[str, str] = (
309309
oauth_response.get("enterprise") or {}
310310
)
311+
is_enterprise_install: bool = (
312+
oauth_response.get("is_enterprise_install") or False
313+
)
311314
installed_team: Dict[str, str] = oauth_response.get("team") or {}
312315
installer: Dict[str, str] = oauth_response.get("authed_user") or {}
313316
incoming_webhook: Dict[str, str] = (
@@ -317,14 +320,20 @@ async def run_installation(self, code: str) -> Optional[Installation]:
317320
bot_token: Optional[str] = oauth_response.get("access_token")
318321
# NOTE: oauth.v2.access doesn't include bot_id in response
319322
bot_id: Optional[str] = None
323+
enterprise_url: Optional[str] = None
320324
if bot_token is not None:
321325
auth_test = await self.client.auth_test(token=bot_token)
322326
bot_id = auth_test["bot_id"]
327+
if is_enterprise_install is True:
328+
enterprise_url = auth_test.get("url")
323329

324330
return Installation(
325331
app_id=oauth_response.get("app_id"),
326332
enterprise_id=installed_enterprise.get("id"),
333+
enterprise_name=installed_enterprise.get("name"),
334+
enterprise_url=enterprise_url,
327335
team_id=installed_team.get("id"),
336+
team_name=installed_team.get("name"),
328337
bot_token=bot_token,
329338
bot_id=bot_id,
330339
bot_user_id=oauth_response.get("bot_user_id"),
@@ -333,10 +342,13 @@ async def run_installation(self, code: str) -> Optional[Installation]:
333342
user_token=installer.get("access_token"),
334343
user_scopes=installer.get("scope"), # comma-separated string
335344
incoming_webhook_url=incoming_webhook.get("url"),
345+
incoming_webhook_channel=incoming_webhook.get("channel"),
336346
incoming_webhook_channel_id=incoming_webhook.get("channel_id"),
337347
incoming_webhook_configuration_url=incoming_webhook.get(
338-
"configuration_url", None
348+
"configuration_url"
339349
),
350+
is_enterprise_install=is_enterprise_install,
351+
token_type=oauth_response.get("token_type"),
340352
)
341353

342354
except SlackApiError as e:

slack_bolt/oauth/oauth_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def run_installation(self, code: str) -> Optional[Installation]:
340340
incoming_webhook_channel=incoming_webhook.get("channel"),
341341
incoming_webhook_channel_id=incoming_webhook.get("channel_id"),
342342
incoming_webhook_configuration_url=incoming_webhook.get(
343-
"configuration_url", None
343+
"configuration_url"
344344
),
345345
is_enterprise_install=is_enterprise_install,
346346
token_type=oauth_response.get("token_type"),

0 commit comments

Comments
 (0)