{
  "id": "security/oauth2-jwt-audience-mismatch",
  "signature": "JWT validation failed: audience 'api://wrong-service' does not match expected audience 'api://my-service'",
  "signature_zh": "JWT验证失败：受众'api://wrong-service'与预期的受众'api://my-service'不匹配",
  "regex": "JWT validation failed: audience '.*' does not match expected audience '.*'",
  "domain": "security",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "The JWT's 'aud' (audience) claim does not match the audience configured for the resource server, often because the token was issued for a different API or the client requested the wrong audience.",
  "root_cause_type": "generic",
  "root_cause_zh": "JWT的'aud'（受众）声明与资源服务器配置的受众不匹配，通常是因为令牌是为不同的API签发的，或者客户端请求了错误的受众。",
  "versions": [
    {
      "version": "Spring Security 6.3.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "MSAL.js 2.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PyJWT 2.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Auth0 SPA SDK 2.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Changing the expected audience in the resource server to accept any audience is insecure, as it would allow tokens meant for other services to access the API.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Modifying the token's 'aud' claim client-side will fail signature validation, as the token is signed and any alteration invalidates the signature.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Clearing the browser cache and retrying does not fix the issue because the token is generated by the identity provider and the audience mismatch is a configuration problem.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Update the resource server configuration to expect the correct audience. For example, in Spring Boot, set `spring.security.oauth2.resourceserver.jwt.audiences=api://my-service`.",
      "success_rate": 0.9,
      "how": "Update the resource server configuration to expect the correct audience. For example, in Spring Boot, set `spring.security.oauth2.resourceserver.jwt.audiences=api://my-service`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure the client application requests the correct audience when obtaining the token. For example, in an Angular app using MSAL, set `extraQueryParameters: {audience: 'api://my-service'}`.",
      "success_rate": 0.85,
      "how": "Ensure the client application requests the correct audience when obtaining the token. For example, in an Angular app using MSAL, set `extraQueryParameters: {audience: 'api://my-service'}`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using Azure AD, verify the API's Application ID URI and ensure the client's API permissions are correctly configured to request that audience.",
      "success_rate": 0.8,
      "how": "If using Azure AD, verify the API's Application ID URI and ensure the client's API permissions are correctly configured to request that audience.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "更新资源服务器配置以期望正确的受众。例如，在Spring Boot中，设置`spring.security.oauth2.resourceserver.jwt.audiences=api://my-service`。",
    "确保客户端应用程序在获取令牌时请求正确的受众。例如，在使用MSAL的Angular应用中，设置`extraQueryParameters: {audience: 'api://my-service'}`。",
    "如果使用Azure AD，请验证API的应用程序ID URI，并确保客户端的API权限配置正确以请求该受众。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.rfc-editor.org/rfc/rfc7519#section-4.1.3",
  "official_doc_section": null,
  "error_code": "JWT_AUDIENCE_MISMATCH",
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-03-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}