Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Conversation

@theresnotime
Copy link

Fixes #7

@totalslacker
Copy link

Is this correct? I still had exceptions as it wanted a dictionary for the headers rather than a string... In my case it was resolved by making sure the nonce was a string:

headers['ACCESS_NONCE'] = str(self.__nonce)

@berlingozzo
Copy link

berlingozzo commented Feb 6, 2021

This doesn't fix it for me, @samtarling .
See new error:

coinbase.get_balance()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.9/site-packages/coinbase/init.py", line 138, in get_balance
return self.get('/account/balance')['amount']
File "/usr/local/lib/python3.9/site-packages/coinbase/init.py", line 122, in get
return self.__rpc.request('GET', path, params)
File "/usr/local/lib/python3.9/site-packages/coinbase/CoinbaseRPC.py", line 75, in request
request = requests.get(url, headers=str(headers))
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 528, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 456, in prepare_request
p.prepare(
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 317, in prepare
self.prepare_headers(headers)
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 449, in prepare_headers
for header in headers.items():
AttributeError: 'str' object has no attribute 'items'

Thanks!

@berlingozzo
Copy link

Turns out if you ONLY apply @totalslacker ' s change, you get past the issue.
However then you get a 404 not found, as this library is still using v1 of the APIs, which I believe is deprecated.
If you change the url base to the v2 url of the apis, you still get a 404, as /account doesn't exist in v2.

For future readers: this library seems to be working with v1 only, which by itself doesn't exist anymore - just found another library.

@JasonG7234
Copy link

just so other people can check it out, what is the other library you found?

@jjasghar
Copy link

jjasghar commented May 5, 2021

Yep, i can confirm that this is still looking at the v1 API. It looks like it's a completely different API for v2, and we'd have to change all the endpoints around.

@j-h-m
Copy link

j-h-m commented Aug 7, 2021

Is this correct? I still had exceptions as it wanted a dictionary for the headers rather than a string... In my case it was resolved by making sure the nonce was a string:

headers['ACCESS_NONCE'] = str(self.__nonce)

This worked for me as well. Other suggested change had no effect.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

requests.exceptions.InvalidHeader: Value for header {ACCESS_NONCE: 1609705740747573} must be of type str or bytes, not <class 'int'>

7 participants