@@ -71,16 +71,22 @@ def _convert_error(error, client_id):
71
71
72
72
73
73
def _read_account_by_id (account_id , correlation_id ):
74
- """Return an instance of MSALRuntimeError or MSALRuntimeAccount, or None"""
74
+ """Return an instance of MSALRuntimeAccount, or log error and return None"""
75
75
callback_data = _CallbackData ()
76
76
pymsalruntime .read_account_by_id (
77
77
account_id ,
78
78
correlation_id ,
79
79
lambda result , callback_data = callback_data : callback_data .complete (result )
80
80
)
81
81
callback_data .signal .wait ()
82
- return (callback_data .result .get_error () or callback_data .result .get_account ()
83
- or None ) # None happens when the account was not created by broker
82
+ error = callback_data .result .get_error ()
83
+ if error :
84
+ logger .debug ("read_account_by_id() error: %s" , _convert_error (error , None ))
85
+ return None
86
+ account = callback_data .result .get_account ()
87
+ if account :
88
+ return account
89
+ return None # None happens when the account was not created by broker
84
90
85
91
86
92
def _convert_result (result , client_id , expected_token_type = None ): # Mimic an on-the-wire response from AAD
@@ -195,8 +201,6 @@ def _acquire_token_silently(
195
201
# acquireTokenSilently is expected to fail. - Sam Wilson
196
202
correlation_id = correlation_id or _get_new_correlation_id ()
197
203
account = _read_account_by_id (account_id , correlation_id )
198
- if isinstance (account , pymsalruntime .MSALRuntimeError ):
199
- return _convert_error (account , client_id )
200
204
if account is None :
201
205
return
202
206
params = pymsalruntime .MSALRuntimeAuthParameters (client_id , authority )
@@ -220,8 +224,6 @@ def _acquire_token_silently(
220
224
def _signout_silently (client_id , account_id , correlation_id = None ):
221
225
correlation_id = correlation_id or _get_new_correlation_id ()
222
226
account = _read_account_by_id (account_id , correlation_id )
223
- if isinstance (account , pymsalruntime .MSALRuntimeError ):
224
- return _convert_error (account , client_id )
225
227
if account is None :
226
228
return
227
229
callback_data = _CallbackData ()
0 commit comments