问题
I'm trying to use S3 API with Bluemix object storage using the following code:
import boto3, pprint, sys;
s3 = boto3.Session().client(
service_name="s3",
region_name="us-geo",
endpoint_url="https://s3-api.us-geo.objectstorage.softlayer.net",
aws_access_key_id="auto-generated-apikey-<redacted>",
aws_secret_access_key="<redacted>");
pprint.pprint(s3.list_buckets());
but keep getting AccessDenied error:
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<Resource></Resource>
<RequestId><redacted></RequestId>
<httpStatusCode>403</httpStatusCode>
</Error>
I took aws_access_key_id and aws_secret_access_key from the "Service Credentials" tab. I used similar code for AWS S3, and it worked. What am I missing?
回答1:
The IAM-enabled cos uses a slightly different syntax for client creation that is supported by a fork of the boto3 library.
Here’s an example in the docs: https://console.bluemix.net/docs/services/cloud-object-storage/libraries/python.html
来源:https://stackoverflow.com/questions/46865225/how-to-authenticate-to-bluemix-s3-lite