From 4e053ffb8b15d2dd4e3411ee2f80548c6f69f1e9 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Wed, 11 Aug 2021 18:39:10 +0900 Subject: [PATCH] Fix a token rotation bug where a bot token is not refreshed if a user token does not exist --- slack_bolt/authorization/async_authorize.py | 5 ++++- slack_bolt/authorization/authorize.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/slack_bolt/authorization/async_authorize.py b/slack_bolt/authorization/async_authorize.py index e41023afa..09db629de 100644 --- a/slack_bolt/authorization/async_authorize.py +++ b/slack_bolt/authorization/async_authorize.py @@ -189,7 +189,10 @@ async def __call__( installation.user_token, ) - if installation.user_refresh_token is not None: + if ( + installation.user_refresh_token is not None + or installation.bot_refresh_token is not None + ): if self.token_rotator is None: raise BoltError(self._config_error_message) refreshed = await self.token_rotator.perform_token_rotation( diff --git a/slack_bolt/authorization/authorize.py b/slack_bolt/authorization/authorize.py index c0627940e..43646b6b3 100644 --- a/slack_bolt/authorization/authorize.py +++ b/slack_bolt/authorization/authorize.py @@ -186,7 +186,10 @@ def __call__( installation.bot_token, installation.user_token, ) - if installation.user_refresh_token is not None: + if ( + installation.user_refresh_token is not None + or installation.bot_refresh_token is not None + ): if self.token_rotator is None: raise BoltError(self._config_error_message) refreshed = self.token_rotator.perform_token_rotation(