@@ -76,6 +76,7 @@ def __init__(
7676 signing_secret : Optional [str ] = None ,
7777 # for single-workspace apps
7878 token : Optional [str ] = None ,
79+ token_verification_enabled : bool = True ,
7980 client : Optional [WebClient ] = None ,
8081 # for multi-workspace apps
8182 authorize : Optional [Callable [..., AuthorizeResult ]] = None ,
@@ -95,6 +96,7 @@ def __init__(
9596 :param process_before_response: True if this app runs on Function as a Service. (Default: False)
9697 :param signing_secret: The Signing Secret value used for verifying requests from Slack.
9798 :param token: The bot access token required only for single-workspace app.
99+ :param token_verification_enabled: Verifies the validity of the given token if True.
98100 :param client: The singleton slack_sdk.WebClient instance for this app.
99101 :param authorize: The function to authorize an incoming request from Slack
100102 by checking if there is a team/user in the installation data.
@@ -227,9 +229,11 @@ def __init__(
227229 )
228230
229231 self ._init_middleware_list_done = False
230- self ._init_middleware_list ()
232+ self ._init_middleware_list (
233+ token_verification_enabled = token_verification_enabled
234+ )
231235
232- def _init_middleware_list (self ):
236+ def _init_middleware_list (self , token_verification_enabled : bool ):
233237 if self ._init_middleware_list_done :
234238 return
235239 self ._middleware_list .append (
@@ -240,7 +244,9 @@ def _init_middleware_list(self):
240244 if self ._oauth_flow is None :
241245 if self ._token is not None :
242246 try :
243- auth_test_result = self ._client .auth_test (token = self ._token )
247+ auth_test_result = None
248+ if token_verification_enabled :
249+ auth_test_result = self ._client .auth_test (token = self ._token )
244250 self ._middleware_list .append (
245251 SingleTeamAuthorization (auth_test_result = auth_test_result )
246252 )
0 commit comments