How to authenticate to Bluemix S3 Lite?

妖精的绣舞 提交于 2019-12-11 10:15:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!