in bonsaicli2/bonsai_cli/aad.py [0:0]
def __init__(self, tenant_id: Optional[str] = None):
self._cache_file = get_aad_cache_file()
self.cache = TokenCache(self._cache_file)
retry_count = 1
effective_tenant_id = (
tenant_id
if tenant_id is not None and tenant_id != "None"
else "organizations"
)
_AAD_AUTHORITY = "https://login.microsoftonline.com/" + effective_tenant_id
while True:
try:
self._app = PublicClientApplication(
_AAD_CLIENT_ID, authority=_AAD_AUTHORITY, token_cache=self.cache
)
if self._app:
break
except ConnectionError as e:
log.info(
"ConnectionError on attempt {} to "
"create msal PublicClientApplication, "
"retrying...".format(retry_count)
)
if retry_count >= 5:
raise e
retry_count += 1