Closed jiasli closed 2 years ago
Even if Azure CLI prints MSAL's log, the content of the exception
log is uncontrollable by Azure CLI.
It is certainly not user-friendly to dump the full traceback in the context of Azure CLI's user experience.
https://docs.python.org/3/library/logging.html#logging.Logger.exception
exception(msg, *args, kwargs) Logs a message with level ERROR on this logger. The arguments are interpreted as for debug(). Exception info is added to the logging message.** This method should only be called from an exception handler.
A simple demo:
import logging
try:
a = 3 / 0
except:
logging.exception("calculation failed.")
Output:
ERROR:root:calculation failed.
Traceback (most recent call last):
File "D:\cli\testproj\main.py", line 4, in <module>
3 / 0
ZeroDivisionError: division by zero
Describe the bug
Currently when refreshing token fails, MSAL silences the exception and logs and error:
https://github.com/AzureAD/microsoft-authentication-library-for-python/blob/62752adbcc8700c9e5969cacdce64c23bb8802c8/msal/application.py#L1206-L1207
Currently Azure CLI doesn't print MSAL's logs, the real cause will be hidden and all Azure CLI can get is a
None
result. Making it impossible for the end user to know what happened:https://github.com/Azure/azure-cli/blob/925d5f93e9caff6fdc74c03b3755d8811d2baf69/src/azure-cli-core/azure/cli/core/auth/util.py#L119-L121
This topic is very similar to the one we discussed in https://github.com/AzureAD/microsoft-authentication-extensions-for-python/issues/92.