IBM / ibm-cos-sdk-java

ibm-cos-sdk-java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CosExample code can't find AWS Access Key ID

hmckinne opened this issue · comments

When trying to run the CosExample sample COS client against my own IBM COS instance, I get this error:

The AWS Access Key ID you provided does not exist in our records. (Service: Amazon S3; Status Code: 403; Error Code: InvalidAccessKeyId; Request ID: f3497ac4-e055-497c-8240-3dc036fe85dd), S3 Extended Request ID: null
I replaced the api_key, service_instance_id and endpoint_url values with those from the COS service credentials. I am using v2.4.2 of the IBM COS SDK.

If I generate HMAC credentials in my COS instance, it does work. Is the example code still current, or could I be doing something wrong?

Hi @hmckinne can you ensure you are creating an instance of BasicIBMOAuthCredentials instead of BasicAWSCredentials when using api key & service instance. If this does not work can you paste in your code?

Thanks, @smcgrath-IBM. I am using the sample code in this repo. I changed the endpoint URL in the sample code to https://s3.us-south.cloud-object-storage.appdomain.cloud, so it is using BasicAWSCredentials. I notice that the parameters for this constructor are access_key and secret_key. Does this imply that HMAC credentials have to be used instead?

Yes, access_key & secret_key are HMAC credentials & an instance of BasicAWSCredentials is required. Api key & service instance use an instance of BasicIBMOAuthCredentials for credentials. Let me know if this resolves your issue.

That makes sense. Thanks.