# User is not authorized to access this resource with an explicit deny

AWS error fixes · Updated 17 November 2026

**Short answer:** A policy evaluated by API Gateway for this request contains a Deny that matches it. Most often that's your Lambda authorizer returning Effect: Deny, or, very commonly, an authorizer that returned an Allow scoped to one method ARN which API Gateway then cached and applied to a different path, so the second request is denied. It can also come from the API's resource policy. Check which, then return a broader resource in the policy or fix the caching key.

## Three different messages

| Message (HTTP 403) | Meaning |
|---|---|
| `User is not authorized to access this resource with an explicit deny` | A policy (authorizer output or resource policy) denies this request |
| `User is not authorized to access this resource` | The authorizer's Allow doesn't cover this method/path (no explicit deny) |
| `Unauthorized` (401) | The authorizer returned or threw `Unauthorized`, or the identity source header was missing |

Enable execution logs on the stage to see the policy the authorizer returned and whether it came from cache.

## The caching trap

Many authorizer examples return a policy for `event.methodArn`, the single method being called:

```
{ "Effect": "Allow", "Action": "execute-api:Invoke",
  "Resource": "arn:aws:execute-api:eu-west-2:123456789012:a1b2c3d4e5/prod/GET/orders" }
```

With authorizer caching on (the console default TTL is 300 seconds), API Gateway caches that policy by the token. The same user's next call to `GET /customers` reuses the cached policy, which doesn't cover it, so it's denied without the authorizer even running. It looks random: the first request after the cache expires works.

**Fix**: return a policy that covers everything the caller may access, for example `arn:aws:execute-api:eu-west-2:123456789012:a1b2c3d4e5/prod/*` or `.../*/*`, and do fine-grained checks in the backend. Or turn caching off (TTL 0), or add the path to the identity sources so the cache key differs per route.

## Other causes

- **The authorizer really denied**: expired or invalid token, wrong audience, a group check. Log the decision inside the authorizer function.
- **Resource policy**: a `Deny` on `aws:SourceIp` or `aws:SourceVpce` in the API's resource policy. Remember that resource policy changes only apply after you **redeploy** the API to the stage.
- **Private APIs**: requests through a VPC endpoint not listed in the resource policy.
- **Resource ARN built wrongly**: a policy that uses the wrong API ID, stage or Region never matches, and a deny-by-default authorizer then denies.

## Test and confirm

1. In the console, open the authorizer and use **Test authorizer** with a real token to see the returned policy.
2. Flush the cache after changing authorizer logic: `aws apigateway flush-stage-authorizers-cache --rest-api-id a1b2c3d4e5 --stage-name prod`.
3. Call two different routes with the same token in quick succession; both should succeed if the policy covers them.
4. Watch the stage's `4XXError` metric settle afterwards.

## Questions

### Why does my Lambda authorizer allow the first request and deny the next one?

Authorizer caching reused a policy scoped to the first method's ARN. Return a wildcard resource covering all allowed routes, or disable or re-key the cache.

### What is the difference between explicit deny and not authorized in API Gateway?

Explicit deny means a policy statement denied the request; plain not authorized means no Allow statement covered it.

### How do I clear the API Gateway authorizer cache?

Run aws apigateway flush-stage-authorizers-cache with the REST API ID and stage name, or set the authorizer TTL to 0.

## When this happens away from your desk

Intermittent 403s get reported by users long before they look like a pattern. CloudConsole, a phone app for AWS, is being built to show API Gateway error metrics and logs on your phone, which makes the pattern easier to see.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Troubleshoot "403 Forbidden" errors with Lambda authorizers (re:Post)](https://repost.aws/knowledge-center/api-gateway-403-error-lambda-authorizer)
- [Use API Gateway Lambda authorizers](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html)

## Related

- [403 Forbidden: User is not authorized to access this resource](https://cloudconsole.dev/errors/api-gateway-403-forbidden)
- [{"message":"Missing Authentication Token"}](https://cloudconsole.dev/errors/api-gateway-missing-authentication-token)
- [CloudWatch alarm for API Gateway 4XXError (REST API)](https://cloudconsole.dev/alarms/api-gateway-4xxerror)
- [Execution failed due to configuration error: Invalid permissions on Lambda function](https://cloudconsole.dev/errors/api-gateway-invalid-permissions-on-lambda)
- [No 'Access-Control-Allow-Origin' header with API Gateway](https://cloudconsole.dev/errors/api-gateway-cors-error)
- [429 Too Many Requests from API Gateway](https://cloudconsole.dev/errors/api-gateway-429-too-many-requests)

---

Source: https://cloudconsole.dev/errors/api-gateway-explicit-deny-lambda-authorizer

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
