{"record":{"id":"59fa1ca7ae915b3a","repo":"apolloconfig/apollo","slug":"user-token-is-required","errorCode":null,"errorMessage":"User token is required","messagePattern":"User token is required","errorType":"exception","errorClass":"AccessDeniedException","httpStatus":403,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/UserTokenOpenApiController.java","lineNumber":417,"sourceCode":"    capability.setDataChangeCreatedTime(toOffsetDateTime(userToken.getDataChangeCreatedTime()));\n    capability.setDenyAll(scope.isDenyAll());\n    capability.setOperations(new LinkedHashSet<>(scope.getOperations()));\n    capability.setAllOperations(!scope.isDenyAll() && scope.getOperations().isEmpty());\n    capability.setAppIds(new LinkedHashSet<>(scope.getAppIds()));\n    capability.setAllApps(!scope.isDenyAll() && scope.getAppIds().isEmpty());\n    capability.setEnvs(new LinkedHashSet<>(scope.getEnvs()));\n    capability.setAllEnvs(!scope.isDenyAll() && scope.getEnvs().isEmpty());\n    capability.setNamespaces(scope.getNamespaces().stream()\n        .map(UserTokenOpenApiController::toOpenNamespaceScope).collect(Collectors.toList()));\n    capability.setAllNamespaces(!scope.isDenyAll() && scope.getNamespaces().isEmpty());\n    capability.setActions(actionsFor(scope).stream().map(UserTokenOpenApiController::toOpenAction)\n        .collect(Collectors.toList()));\n    return ResponseEntity.ok(capability);\n  }\n\n  private UserToken requireUserToken() {\n    if (!UserIdentityConstants.USER_TOKEN.equals(UserIdentityContextHolder.getAuthType())) {\n      throw new AccessDeniedException(\"User token is required\");\n    }\n    UserToken userToken = userTokenAuthUtil.retrieveUserTokenFromCtx();\n    if (userToken == null) {\n      throw new AccessDeniedException(\"User token is required\");\n    }\n    return userToken;\n  }\n\n  private List<UserTokenOpenApiAction> actionsFor(UserTokenScope scope) {\n    return ACTION_CATALOG.stream().filter(action -> allowsAction(scope, action))\n        .map(action -> withGrantedOperations(scope, action)).collect(Collectors.toList());\n  }\n\n  private boolean allowsAction(UserTokenScope scope, UserTokenOpenApiAction action) {\n    List<String> requiredOperations = action.getRequiredOperations();\n    if (requiredOperations == null || requiredOperations.isEmpty()) {\n      return true;\n    }","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/UserTokenOpenApiController.java#L399-L435","documentation":"Thrown by requireUserToken when the auth type is not USER_TOKEN or when no user token can be retrieved from the request context.","triggerScenarios":"Thrown when the UserToken OpenAPI endpoint is called without supplying the required user token in the request header or parameter.","commonSituations":"Missing token header; blank token value; token stripped by a proxy.","solutions":["Send the request with a valid user token (auth type USER_TOKEN); sessions and consumer tokens are rejected by this endpoint.","Ensure the user token is present in the request context and resolvable to an existing token record."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}