CodexBloom - Programming Q&A Platform

OCI Data Science Notebook how to to Access Datasets in Object Storage - 403 Forbidden scenarios

👀 Views: 198 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-08
OCI Object Storage Data Science Python

I've been struggling with this for a few days now and could really use some help. I'm currently working on an OCI Data Science project where I'm trying to access datasets stored in OCI Object Storage from my Jupyter Notebook instance. Despite following the necessary configurations, I keep working with a `403 Forbidden` behavior when attempting to load the datasets. The code snippet I am using to access the data looks like this: ```python import oci config = oci.config.from_file() object_storage_client = oci.object_storage.ObjectStorageClient(config) bucket_name = 'my_bucket' namespace = object_storage_client.get_namespace().data object_name = 'my_dataset.csv' try: response = object_storage_client.get_object(namespace, bucket_name, object_name) data = response.data.text except oci.exceptions.ServiceError as e: print(f'behavior: {e}') ``` I've made sure that the notebook instance has the necessary IAM policies allowing access to the Object Storage service. The policy I created is as follows: ``` Allow group <my_group> to manage object-family in compartment <my_compartment> ``` However, even with this policy in place, I'm still getting the forbidden behavior. I've double-checked the namespace and the bucket name, and they are correct. I've also verified that the dataset actually exists in the specified bucket. As a troubleshooting step, I tried accessing the same Object Storage resource via the OCI CLI and it works without any issues, so it seems to be specific to the notebook instance. I'm using the latest version of the OCI SDK for Python, which is 2.45.0. Any insights on what might be causing this access scenario would be greatly appreciated. This is happening in both development and production on Debian. For reference, this is a production REST API. I'd be grateful for any help. For context: I'm using Python on Debian. Thanks, I really appreciate it!