CodexBloom - Programming Q&A Platform

OCI Object Storage: Encountering '403 Forbidden' Error When Uploading Files Using Python SDK 2.22.0

πŸ‘€ Views: 0 πŸ’¬ Answers: 1 πŸ“… Created: 2025-09-06
Oracle OCI Object Storage Python SDK

I'm working through a tutorial and I'm optimizing some code but Quick question that's been bugging me - I've been banging my head against this for hours... I'm trying to upload files to an OCI Object Storage bucket using the Python SDK (version 2.22.0), but I'm getting a '403 Forbidden' error. This occurs when I attempt to invoke the `upload_object` method. Here’s the relevant code snippet: ```python import oci config = oci.config.from_file() # Loads the default config object_storage_client = oci.object_storage.ObjectStorageClient(config) bucket_name = 'my-bucket' namespace = object_storage_client.get_namespace().data try: with open('path/to/myfile.txt', 'rb') as f: object_storage_client.put_object(namespace, bucket_name, 'myfile.txt', f) except oci.exceptions.ServiceError as e: print(f'Error: {e}') ``` I've verified that the bucket exists and that I have the correct permissions set in the IAM policy. The policy allows `objectstorage:objects:put` and is assigned to the group I'm a member of. I also confirmed that the API key and region in my config file are correct. However, I'm still running into this error. I've tried using different files and double-checked the bucket name for any typos. Is there something I'm missing, or could it be a permissions issue that I overlooked? Any help would be appreciated! What am I doing wrong? Thanks in advance! My development environment is Linux. Am I missing something obvious? My development environment is Linux. How would you solve this? My team is using Python for this service. How would you solve this? This issue appeared after updating to Python 3.10. What are your experiences with this? For reference, this is a production REST API. Any suggestions would be helpful.