{"record":{"id":"37679c5c6368be7a","repo":"BerriAI/litellm","slug":"azure-ad-token-must-be-a-string-got-type-token","errorCode":null,"errorMessage":"Azure AD token must be a string, got {type(token)}","messagePattern":"Azure AD token must be a string, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure/common_utils.py","lineNumber":373,"sourceCode":"            )\n            raise e\n\n        #########################################################\n        # If litellm.enable_azure_ad_token_refresh is True and no other token provider is available,\n        # try to get DefaultAzureCredential provider\n        #########################################################\n        if azure_ad_token_provider is None and azure_ad_token is None:\n            azure_ad_token_provider = BaseAzureLLM._try_get_default_azure_credential_provider(\n                scope=scope,\n            )\n\n    # Execute the token provider to get the token if available\n    if azure_ad_token_provider and callable(azure_ad_token_provider):\n        try:\n            token: Final = azure_ad_token_provider()\n            if not isinstance(token, str):\n                verbose_logger.error(\"Azure AD token provider returned non-string value: %s\", type(token))\n                raise TypeError(f\"Azure AD token must be a string, got {type(token)}\")\n            else:\n                azure_ad_token = token\n        except TypeError:\n            # Re-raise TypeError directly\n            raise\n        except Exception as e:\n            verbose_logger.error(\"Error calling Azure AD token provider: %s\", e)\n            raise RuntimeError(f\"Failed to get Azure AD token: {e}\") from e\n\n    return azure_ad_token\n\n\nclass BaseAzureLLM(BaseOpenAILLM):\n    @staticmethod\n    def _try_get_default_azure_credential_provider(\n        scope: str,\n    ) -> Callable[[], str] | None:\n        \"\"\"","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/azure/common_utils.py#L355-L391","documentation":"Error \"Azure AD token must be a string, got {type(token)}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/azure/common_utils.py:373 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return the Azure AD token as a string from your token provider, not a dict or bytes."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}