{"record":{"id":"a7f975e63401a6ec","repo":"abpframework/abp","slug":"volo-authorization-010001","errorCode":"Volo.Authorization:010001","errorMessage":"Authorization failed! Given policy has not granted.","messagePattern":"Authorization failed! Given policy has not granted\\.","errorType":"exception","errorClass":"AbpAuthorizationException","httpStatus":403,"severity":"error","filePath":"framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs","lineNumber":164,"sourceCode":"    public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, AuthorizationPolicy policy)\n    {\n        if (!await authorizationService.IsGrantedAsync(resource, policy))\n        {\n            throw new AbpAuthorizationException(code: AbpAuthorizationErrorCodes.GivenPolicyHasNotGrantedForGivenResource)\n                .WithData(\"ResourceName\", resource);\n        }\n    }\n\n    /// <summary>\n    /// Checks if CurrentPrincipal meets a specific authorization policy, throwing an <see cref=\"AbpAuthorizationException\"/> if not.\n    /// </summary>\n    /// <param name=\"authorizationService\">The <see cref=\"IAuthorizationService\"/> providing authorization.</param>\n    /// <param name=\"policy\">The policy to evaluate.</param>\n    public static async Task CheckAsync(this IAuthorizationService authorizationService, AuthorizationPolicy policy)\n    {\n        if (!await authorizationService.IsGrantedAsync(policy))\n        {\n            throw new AbpAuthorizationException(code: AbpAuthorizationErrorCodes.GivenPolicyHasNotGranted);\n        }\n    }\n\n    /// <summary>\n    /// Checks if CurrentPrincipal meets a specific authorization policy against the specified resource, throwing an <see cref=\"AbpAuthorizationException\"/> if not.\n    /// </summary>\n    /// <param name=\"authorizationService\">The <see cref=\"IAuthorizationService\"/> providing authorization.</param>\n    /// <param name=\"resource\">The resource to evaluate the policy against.</param>\n    /// <param name=\"requirements\">The requirements to evaluate the policy against.</param>\n    public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, IEnumerable<IAuthorizationRequirement> requirements)\n    {\n        if (!await authorizationService.IsGrantedAsync(resource, requirements))\n        {\n            throw new AbpAuthorizationException(code: AbpAuthorizationErrorCodes.GivenRequirementsHasNotGrantedForGivenResource)\n                .WithData(\"ResourceName\", resource);\n        }\n    }\n","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs#L146-L182","documentation":"Thrown by CheckAsync(this IAuthorizationService, AuthorizationPolicy policy) when IsGrantedAsync(policy) is false. Error code Volo.Authorization:010001 (GivenPolicyHasNotGranted). Unlike error 010002 this variant takes a compiled AuthorizationPolicy object (not a name) and carries no resource data.","triggerScenarios":"Calling authorizationService.CheckAsync(compiledPolicy) where the policy's requirements are not satisfied by the current principal (no resource in scope).","commonSituations":"User lacks a role/claim the policy requires; policy built with RequireRole/RequireClaim that the principal doesn't have; requirement handler registered but always denies; policy built at runtime with the wrong builder calls.","solutions":["Confirm the current principal has the roles/claims the policy RequireRole/RequireClaim calls demand.","Ensure every requirement in the policy has a registered handler that can Succeed.","If access should be allowed, inspect the policy builder chain for overly strict requirements.","Switch to a named policy (CheckAsync(policyName)) for easier diagnosis if applicable."],"exampleFix":"// before\nvar policy = new AuthorizationPolicyBuilder().RequireRole(\"Admin\").Build();\nawait AuthorizationService.CheckAsync(policy); // throws 010001\n// after: ensure user is Admin, or relax the policy appropriately","handlingStrategy":"validation","validationCode":"if (!await authorizationService.IsGrantedAsync(compiledPolicy))\n{\n    // return 403 instead of letting CheckAsync throw\n}","typeGuard":"null","tryCatchPattern":"try { await authorizationService.CheckAsync(policy); }\ncatch (AbpAuthorizationException ex) when (ex.Code == \"Volo.Authorization:010001\")\n{ /* handle forbidden; no resource in scope */ }","preventionTips":["Confirm the principal has every role/claim the policy requires.","Register a handler for each requirement in the policy.","Use IsGrantedAsync to gate features in the UI.","Consider named policies for runtime-configurable access."],"tags":["authorization","abp","security","policy"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}