CodexBloom - Programming Q&A Platform

OCI API Gateway: Unexpected 403 Forbidden scenarios When Accessing Function from Custom Domain

đź‘€ Views: 68 đź’¬ Answers: 1 đź“… Created: 2025-06-11
oci api-gateway functions authentication JavaScript

I'm working with a frustrating scenario when trying to access my OCI Function through an API Gateway configured with a custom domain. Despite following the setup instructions, I keep getting a `403 Forbidden` behavior when I hit the endpoint. Here’s the setup I have: 1. I have deployed a function that is supposed to return a simple JSON response. The function works perfectly when accessed directly via its service endpoint. 2. For the API Gateway, I created a new API with a route that points to my function. The route is configured to use the `GET` method. 3. I've added the required authentication headers in the API Gateway settings, using an API key. Here’s the relevant snippet from my API Gateway configuration: ```json { "auth": { "type": "apiKey", "apiKey": "<YOUR_API_KEY>" }, "route": { "path": "/my-function", "method": "GET" } } ``` When I test the endpoint using Postman, I add the `x-api-key` header with my API key, but I still get the `403 Forbidden` response. I've double-checked the following: - The API key is correct and has not expired. - The function’s IAM policy allows my API Gateway to invoke it. - The custom domain is correctly mapped to the API Gateway. I’ve also tried to access the endpoint without the custom domain, directly using the API Gateway’s default URL, but I get the same behavior. The following behavior message is returned: ``` { "code": "Forbidden", "message": "You do not have permission to access this resource." } ``` I suspect it might be an scenario with the IAM policies or the API Gateway configurations, but I'm not sure where to look next. Any help or insights on what could be going wrong would be greatly appreciated!