Skip to content
This repository has been archived by the owner on Aug 9, 2018. It is now read-only.

What type to use for client_id, api_key, api_secret #14

Open
Salan54 opened this issue Dec 8, 2017 · 1 comment
Open

What type to use for client_id, api_key, api_secret #14

Salan54 opened this issue Dec 8, 2017 · 1 comment

Comments

@Salan54
Copy link

Salan54 commented Dec 8, 2017

c = '12345'
k = 'xxxxx'
s = 'yyyyy'
api.account_balance(c, k, s)

~/.virtualenvs/bitstamp/lib/python3.6/site-packages/bitstampy/api.py in account_balance(client_id, api_key, api_secret)
     38 def account_balance(client_id, api_key, api_secret):
     39     return (
---> 40         calls.APIAccountBalanceCall(client_id, api_key, api_secret)
     41         .call()
     42     )

~/.virtualenvs/bitstamp/lib/python3.6/site-packages/bitstampy/calls.py in call(self, **params)
     79         message = nonce + self.client_id + self.api_key
     80         signature = hmac.new(
---> 81             self.api_secret, msg=message, digestmod=hashlib.sha256)
     82         signature = signature.hexdigest().upper()
     83         params.update({

~/.virtualenvs/bitstamp/lib/python3.6/hmac.py in new(key, msg, digestmod)
    142     method.
    143     """
--> 144     return HMAC(key, msg, digestmod)

~/.virtualenvs/bitstamp/lib/python3.6/hmac.py in __init__(self, key, msg, digestmod)
     40 
     41         if not isinstance(key, (bytes, bytearray)):
---> 42             raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).__name__)
     43 
     44         if digestmod is None:

TypeError: key: expected bytes or bytearray, but got 'str'


Changed key to bytes :

k = b'xxxxx'
Then :

api.account_balance(c, k, s)

TypeError                                 Traceback (most recent call last)
<ipython-input-27-35f3ae0e7115> in <module>()
----> 1 api.account_balance(c, k, s)

~/.virtualenvs/bitstamp/lib/python3.6/site-packages/bitstampy/api.py in account_balance(client_id, api_key, api_secret)
     38 def account_balance(client_id, api_key, api_secret):
     39     return (
---> 40         calls.APIAccountBalanceCall(client_id, api_key, api_secret)
     41         .call()
     42     )

~/.virtualenvs/bitstamp/lib/python3.6/site-packages/bitstampy/calls.py in call(self, **params)
     77     def call(self, **params):
     78         nonce = self._get_nonce()
---> 79         message = nonce + self.client_id + self.api_key
     80         signature = hmac.new(
     81             self.api_secret, msg=message, digestmod=hashlib.sha256)

TypeError: must be str, not bytes

I am rather confused. Could you please clarify the argument types to use for client_id, api_key, api_secret ? Thanks

@iqdecay
Copy link

iqdecay commented Apr 7, 2018

Have you found how to make this work ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants