I have a Bolt app that has token rotation enabled with the following configuration:
oauth_settings = OAuthSettings(
client_id=...,
client_secret=...,
scopes=...,
user_scopes=...,
installation_store=FileInstallationStore(base_dir=oauth_config["install_store"]),
state_store=FileOAuthStateStore(expiration_seconds=600, base_dir=oauth_config["state_store"]),
token_rotation_expiration_minutes=10
)
app = App(
signing_secret=oauth_config["signing_secret"],
oauth_settings=oauth_settings,
)
with the following events being handled: app_home_opened and message. But after a while, some of its users are receiving the following error in the Slack Bolt middleware:
Traceback (most recent call last):
File "/home/ubuntu/slackbot/lib/python3.10/site-packages/slack_bolt/app/app.py", line 509, in dispatch
resp = middleware.process(req=req, resp=resp, next=middleware_next)
File "/home/ubuntu/slackbot/lib/python3.10/site-packages/slack_bolt/middleware/authorization/multi_teams_authorization.py", line 58, in process
auth_result: Optional[AuthorizeResult] = self.authorize(
File "/home/ubuntu/slackbot/lib/python3.10/site-packages/slack_bolt/authorization/authorize.py", line 220, in __call__
refreshed = self._rotate_and_save_tokens_if_necessary(
File "/home/ubuntu/slackbot/lib/python3.10/site-packages/slack_bolt/authorization/authorize.py", line 331, in _rotate_and_save_tokens_if_necessary
refreshed: Optional[Installation] = self.token_rotator.perform_token_rotation(
File "/home/ubuntu/slackbot/lib/python3.10/site-packages/slack_sdk/oauth/token_rotation/rotator.py", line 40, in perform_token_rotation
rotated_bot: Optional[Bot] = self.perform_bot_token_rotation( # type: ignore
File "/home/ubuntu/slackbot/lib/python3.10/site-packages/slack_sdk/oauth/token_rotation/rotator.py", line 99, in perform_bot_token_rotation
raise SlackTokenRotationError(e)
slack_sdk.errors.SlackTokenRotationError: The request to the Slack API failed. (url: https://www.slack.com/api/oauth.v2.access)
The server responded with: {'ok': False, 'error': 'invalid_refresh_token'}
The only difference between these users and those not getting these messages are, the former have uninstalled and reinstalled the app a couple of times. From the docs, Bolt handles Token Rotation on its own and there's no other implementation required by devs. Is this correct? If not, what's the correct way to retrieve the correct Refresh tokens during Token Rotation? Any advice helps. Thanks.
I have a Bolt app that has token rotation enabled with the following configuration:
with the following events being handled:
app_home_openedandmessage. But after a while, some of its users are receiving the following error in the Slack Bolt middleware:The only difference between these users and those not getting these messages are, the former have uninstalled and reinstalled the app a couple of times. From the docs, Bolt handles Token Rotation on its own and there's no other implementation required by devs. Is this correct? If not, what's the correct way to retrieve the correct Refresh tokens during Token Rotation? Any advice helps. Thanks.