Skip to content

Commit 8422ea3

Browse files
committed
Tolerate authority validation error if opting in a region
1 parent 84fca2d commit 8422ea3

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

msal/application.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,24 @@ def __init__(
282282

283283
self.app_name = app_name
284284
self.app_version = app_version
285-
self.authority = Authority(
285+
286+
# Here the self.authority will not be the same type as authority in input
287+
try:
288+
self.authority = Authority(
286289
authority or "https://login.microsoftonline.com/common/",
287290
self.http_client, validate_authority=validate_authority)
288-
# Here the self.authority is not the same type as authority in input
291+
except ValueError: # Those are explicit authority validation errors
292+
raise
293+
except Exception: # The rest are typically connection errors
294+
if validate_authority and region:
295+
# Since caller opts in to use region, here we tolerate connection
296+
# errors happened during authority validation at non-region endpoint
297+
self.authority = Authority(
298+
authority or "https://login.microsoftonline.com/common/",
299+
self.http_client, validate_authority=False)
300+
else:
301+
raise
302+
289303
self.token_cache = token_cache or TokenCache()
290304
self._region_configured = region
291305
self._region_detected = None

0 commit comments

Comments
 (0)