microsoft/autogen · error · Error
Unauthorized
Error message
Unauthorized
What it means
Raised when `embedding_provider="azure_openai"` is configured but the `openai` and/or `azure-identity` packages are not installed in the environment. The import is done lazily inside _get_embedding so the base tool works without them, but the Azure OpenAI embedding path has a hard dependency on AsyncAzureOpenAI and DefaultAzureCredential.
Source
Thrown at python/packages/autogen-studio/frontend/src/auth/api.ts:80
if (!data.token || !data.user) {
throw new Error("Authentication failed");
}
return data;
} catch (error) {
console.error("Error handling auth callback:", error);
throw error;
}
}
async getCurrentUser(token: string): Promise<User> {
try {
const response = await fetch(`${this.getBaseUrl()}/auth/me`, {
headers: this.getHeaders(token),
});
if (response.status === 401) {
throw new Error("Unauthorized");
}
const data = await response.json();
return data;
} catch (error) {
console.error("Error getting current user:", error);
throw error;
}
}
async checkAuthType(): Promise<{ type: string }> {
try {
const response = await fetch(`${this.getBaseUrl()}/auth/type`, {
headers: this.getHeaders(),
});
const data = await response.json();
return data;View on GitHub (pinned to 027ecf0a37)
Solutions
- Install the SDKs: `uv add openai azure-identity` (or `pip install openai azure-identity`) in the same environment running the tool.
- Verify with `python -c "from openai import AsyncAzureOpenAI; from azure.identity import DefaultAzureCredential"` before deploying.
- Alternatively switch to a provider whose deps you already ship, or drop client-side embeddings.
Example fix
# before: ImportError at query time # config.embedding_provider = "azure_openai" # after # shell: # uv add openai azure-identity # (no code change required)
Defensive patterns
Strategy: validation
Validate before calling
def azure_openai_deps_available() -> bool:
try:
from openai import AsyncAzureOpenAI # noqa: F401
from azure.identity import DefaultAzureCredential # noqa: F401
return True
except ImportError:
return False Try / catch
try:
results = await tool.run(query)
except ImportError as e:
if "azure-identity" in str(e) or "openai" in str(e):
raise SystemExit("Install openai + azure-identity before using azure_openai embeddings") from e
raise Prevention
- Declare openai and azure-identity as explicit dependencies when your config uses azure_openai embeddings.
- Add an import smoke test to your CI/deploy pipeline.
When it happens
Trigger: Choosing embedding_provider='azure_openai' with vector_fields, then executing a search — the try-import of `openai.AsyncAzureOpenAI` / `azure.identity.DefaultAzureCredential` fails with ImportError which is re-raised with install instructions.
Common situations: Installing autogen-ext without the openai/azure extras; running in a slim container or lambda where optional deps were pruned; using a dependency resolver that dropped openai after a lock-file regeneration.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Template ${templateId} not found for component type ${compon
- Workbench template ${templateId} not found
- ${componentType} template ${templateId} not found
- Failed to fetch galleries
- Authentication failed
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/11125f6edb2c9fff.
Report an issue: GitHub.