BerriAI/litellm · error · RuntimeError
Failed to get Azure AD token
Error message
Failed to get Azure AD token: {e} What it means
Error "Failed to get Azure AD token: {e}" thrown in BerriAI/litellm.
Solutions
- Check the inner exception '{e}'; verify AZURE_TENANT_ID/AZURE_CLIENT_ID/AZURE_CLIENT_SECRET and network access to login.microsoftonline.com.
When it happens
Trigger: Thrown at litellm/llms/azure/common_utils.py:381 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/2c63ec4de5fb2a53.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/azure/common_utils.py:381
azure_ad_token_provider = BaseAzureLLM._try_get_default_azure_credential_provider(
scope=scope,
)
# Execute the token provider to get the token if available
if azure_ad_token_provider and callable(azure_ad_token_provider):
try:
token: Final = azure_ad_token_provider()
if not isinstance(token, str):
verbose_logger.error("Azure AD token provider returned non-string value: %s", type(token))
raise TypeError(f"Azure AD token must be a string, got {type(token)}")
else:
azure_ad_token = token
except TypeError:
# Re-raise TypeError directly
raise
except Exception as e:
verbose_logger.error("Error calling Azure AD token provider: %s", e)
raise RuntimeError(f"Failed to get Azure AD token: {e}") from e
return azure_ad_token
class BaseAzureLLM(BaseOpenAILLM):
@staticmethod
def _try_get_default_azure_credential_provider(
scope: str,
) -> Callable[[], str] | None:
"""
Try to get DefaultAzureCredential provider
Args:
scope: Azure scope for the token
Returns:
Token provider callable if DefaultAzureCredential is enabled and available, None otherwise
"""View on GitHub (pinned to 77b7c6c40c)