CodexBloom - Programming Q&A Platform

OCI Object Storage Pre-Signed URL Expiration Not Matching Expected Timeframe

👀 Views: 1 💬 Answers: 1 📅 Created: 2025-06-08
oci object-storage presigned-url Python

I'm updating my dependencies and I'm stuck on something that should probably be simple... I'm having trouble with pre-signed URLs generated for my Oracle Cloud Infrastructure (OCI) Object Storage. I am using the `oci-python-sdk` version 2.36.0 to generate the URLs, but they seem to expire much sooner than the `expiration_time` I set. I expected them to be valid for 1 hour, but they only work for about 15 minutes. Here's the code I'm using to generate the pre-signed URL: ```python import oci import datetime config = oci.config.from_file() # Load configuration from ~/.oci/config object_storage_client = oci.object_storage.ObjectStorageClient(config) namespace = object_storage_client.get_namespace().data bucket_name = 'my_bucket' object_name = 'my_object.txt' # Set expiration to 1 hour from now expiration_time = datetime.datetime.utcnow() + datetime.timedelta(hours=1) # Generate pre-signed URL url = object_storage_client.generate_presigned_url( 'GET', namespace, bucket_name, object_name, expires=expiration_time ) print(f'Pre-signed URL: {url}') ``` When I check the URL after generating it, I can access the object just fine. However, after about 15 minutes, any attempts to use the URL result in a `403 Forbidden` behavior, indicating that the URL has expired. I double-checked the `expiration_time`, and it seems correctly set to an hour later. I also verified that my OCI Object Storage bucket policies allow public access to this specific file, so permissions shouldn’t be the scenario. I've tried regenerating the URL several times and ensured my system clock is synchronized. Is there something I might be missing or a potential bug in the SDK? Any insights would be appreciated. For context: I'm using Python on Linux. I'm working on a service that needs to handle this. How would you solve this? I'm working in a Ubuntu 22.04 environment. I'd be grateful for any help. Thanks for taking the time to read this!