CodexBloom - Programming Q&A Platform

OCI Object Storage: Receiving 403 Forbidden scenarios When Accessing Bucket with Pre-signed URL

👀 Views: 30 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-15
oci object-storage pre-signed-url 403-forbidden Python

This might be a silly question, but I'm refactoring my project and I'm relatively new to this, so bear with me..... I'm trying to generate a pre-signed URL for an object in my OCI Object Storage bucket, but I keep working with a `403 Forbidden` behavior when I attempt to access the URL. I've followed the documentation closely, but something seems to be off in my configuration. Here's the relevant part of my Python code using the `oci` SDK: ```python import oci config = oci.config.from_file() # Load config from ~/.oci/config object_storage_client = oci.object_storage.ObjectStorageClient(config) bucket_name = 'my_bucket' namespace = object_storage_client.get_namespace().data object_name = 'test_file.txt' # Generate pre-signed URL for the object pre_signed_url = object_storage_client.generate_pre_signed_url( namespace_name=namespace, bucket_name=bucket_name, object_name=object_name, expiry_seconds=3600 # Valid for 1 hour ) print(pre_signed_url) ``` After generating the pre-signed URL, I try accessing it via a browser, but I get this behavior message: ``` 403 Forbidden: Access denied. ``` I've checked the IAM policies and confirmed that the user has `OBJECT_READ` permission on the bucket. I've also verified that the object exists in the bucket. To add to the confusion, when I directly access the object through the OCI console, it works perfectly. Here are some specific things I've attempted to troubleshoot: - Regenerated the pre-signed URL several times. - Verified the expiration time to ensure it's set correctly. - Checked for any conflicting policies that might restrict access. I'm using version `2.40.0` of the OCI Python SDK. Any insights on what might be causing this scenario would be greatly appreciated! For context: I'm using Python on macOS. Any examples would be super helpful. This is happening in both development and production on Windows 11.