Closed kundanone closed 2 years ago
Could you provide more detail or perhaps a code sample? Looking up the failure, this check is for validating the region name, not the API key used for authentication: https://github.com/IBM/ibm-cos-sdk-python-core/blob/18e8a854a2a4fdca7fbb50d5b80fb666734def1f/ibm_botocore/session.py#L752. Are you sure you are passing the correct values into the correct fields?
Below is the sample code for generating presigned URL which throws this error.
import ibm_boto3
myserviceapikey = "abcA6raWVUVEdfGXG4IpKC1EZV4kt4-OH4klr_qtoXyZ"
myendpointurl = "https://s3.us-south.cloud-object-storage.appdomain.cloud"
config = {"cos_hmac_keys": {}}
config["cos_hmac_keys"]["access_key_id"] = "1231104d3bd348c283c98f99fddf0xyz"
config["cos_hmac_keys"]["secret_access_key"] = "abc9fa48ee0e5e27e079d365c5aa3c19d6a48a2064669xyz"
mybucket = "mybucket"
myobject = "myfile.txt"
cos = ibm_boto3.client('s3', myserviceapikey, endpoint_url=myendpointurl, aws_access_key_id=config["cos_hmac_keys"]["access_key_id"], aws_secret_access_key=config["cos_hmac_keys"]["secret_access_key"])
theURL=cos.generate_presigned_url('get_object', Params = {'Bucket': mybucket, 'Key': myobject}, ExpiresIn = 3600)
print(theURL)
PS: I have replaced some sensitive characters with different ones.
Thank you for the sample. I can reproduce your issue using Python 3.9.6, version 2.10.0 of the SDK, and valid credentials. The problem has nothing to do with presigned URLs; the exception happens when creating the client. Your function call is populating region_name
with myserviceapikey
because it is the next argument in the function signature: https://github.com/IBM/ibm-cos-sdk-python/blob/master/ibm_boto3/session.py#L223. You want to pass that value to ibm_api_key_id=
instead.
If this resolves your issue, please close this ticket.
Thank you. Closing th ticket.
When I generate a service API key, it has "-" in the string which fails the validation : e.g. api key: ***V4kt4-OH4klr_qtoXsF Stack trace:
I can see that the root cause is its validator method: link: https://github.com/IBM/ibm-cos-sdk-python-core/blob/18e8a854a2a4fdca7fbb50d5b80fb666734def1f/ibm_botocore/utils.py#L1004
Workaround: comment out last two lines:
the validator needs to be updated as it is not accepting the new API key which has "-'' char in it.