name: jwt_403_debug_expert description: Diagnose 401/403 responses at the AI Citadel APIM gateway — decode JWT claims, verify Access Contract scope grants, and validate Foundry managed-identity token audience.
jwt_403_debug_expert
When to use
The SRE Agent should invoke this skill when:
- A user reports a 401 or 403 from the Citadel gateway
- A hosted agent's BYOK call returns "Authentication failed with provider … (HTTP 401)" but the underlying provider is the Citadel-routed AOAI
- After running
citadel-spoke-onboarding, the new spoke can't reach the gateway
Investigation flow
Get the correlation ID of the failing request from the user or from the application's logs.
Pull the request from APIM diagnostics:
ApiManagementGatewayLogs | where TimeGenerated > ago(2h) | where CorrelationId == "<id>" | project TimeGenerated, OperationId, ApiId, ProductId, ResponseCode, BackendStatusReason, LastErrorReason, RequestHeaders, ResponseHeadersDecode the JWT if present (claims only — NEVER the signature):
aud— must match the gateway URL configured in the Access Contractiss— must behttps://login.microsoftonline.com/<tenant>/v2.0oid— the calling principal's object IDscp/roles— must include the operation scope (e.g.llm:read)exp— must not be in the past
Match against the Access Contract:
Symptom Root cause Fix audmismatchToken issued for wrong audience Re-issue token with correct audience Missing scope claim Access Contract didn't grant this scope Re-run citadel-spoke-onboarding with the needed scope in gbb_access_contractsexpin pastToken expired (default ~1h for MI) Refresh; check caller's token-cache TTL No AuthorizationheaderCaller using product-key path but no key Set Ocp-Apim-Subscription-Keyor switch to JWT403 with valid JWT Per-product policy denies Check rate-limit-by-keyand product subscription stateOutput: classification, root cause hypothesis, ONE recommended fix and ONE verification step.
Tools
This skill uses:
RunAzCliReadCommandsQueryLogAnalyticsByWorkspaceId
Safety
- NEVER display the JWT signature, named-value contents, or any signing material
- Refer to credentials by resource name only (e.g. "Foundry MI on project
aifp-pilot") - Read-only investigation; any RBAC change requires human action