IBM / ibm-cos-sdk-python

ibm-cos-sdk-python
Apache License 2.0
46 stars 26 forks source link

How to create Session with api key? #14

Closed gilv closed 6 years ago

gilv commented 6 years ago

I need to create Session with API Key.

iam_api_key = 'MY KEY'
iam_serice_endpoint = 'https://s3-api.us-geo.objectstorage.softlayer.net'
iam_service_id = 'ServiceId-123'

token_manager = DefaultTokenManager(api_key_id=iam_api_key)
session = ibm_boto3.session.Session(token_manager=token_manager, ibm_service_instance_id=iam_service_id)

It doesn't work, getting

File "/usr/local/lib/python3.6/site-packages/ibm_botocore/auth.py", line 711,
in get_signature  return self.sign_string(string_to_sign)
File "/usr/local/lib/python3.6/site-packages/ibm_botocore/auth.py", line 621, in sign_string
new_hmac = hmac.new(self.credentials.secret_key.encode('utf-8'),
AttributeError: 'NoneType' object has no attribute 'encode'

I do manage to create Session with access key and secret key. This one for example, works fine:

session = ibm_boto3.session.Session(aws_access_key_id=access_key,   
aws_secret_access_key=secret_key)
gilv commented 6 years ago

@paul-carron can you please check this? thanks

paul-carron commented 6 years ago

Currently looking into it. Will update shortly.

gilv commented 6 years ago

@paul-carron thanks. I also tried without TokenManager and provide api key directly to ibm_boto3.session.Session(...) Got the same exception

paul-carron commented 6 years ago

Can you send your whole script? I'm not getting any issue when I try to replicate based on the info. provided above.

gilv commented 6 years ago

@paul-carron thanks...i will do some checks again