TypeError with API Key Authentication using Coinbase Python3 Client Library

i am using the Unofficial Coinbase Python3 Client Library from GitHub - resy/coinbase_python3: Unofficial Coinbase Python3 Client Library as per as referred to in the documentation.

import coinbase

api_key = ‘XXXXX’
api_secret = ‘XXXXX’

coinbase = coinbase.Coinbase.with_api_key(api_key, api_secret)
user = coinbase.get_user()

leads to a typerror.

Traceback (most recent call last):
File “C:\Users\heino\Documents\Python\CoinbaseLearn2\main.py”, line 7, in
user = coinbase.get_user()
File “C:\Users\heino\AppData\Local\Programs\Python\Python310\lib\coinbase_init_.py”, line 248, in get_user
return self.get(‘/users’)[‘users’][0][‘user’]
File “C:\Users\heino\AppData\Local\Programs\Python\Python310\lib\coinbase_init_.py”, line 122, in get
return self.__rpc.request(‘GET’, path, params)
File “C:\Users\heino\AppData\Local\Programs\Python\Python310\lib\coinbase\CoinbaseRPC.py”, line 75, in request
request = requests.get(url, headers=headers)
File “C:\Users\heino\AppData\Local\Programs\Python\Python310\lib\requests\api.py”, line 73, in get
return request(“get”, url, params=params, **kwargs)
File “C:\Users\heino\AppData\Local\Programs\Python\Python310\lib\requests\api.py”, line 59, in request
return session.request(method=method, url=url, **kwargs)
File “C:\Users\heino\AppData\Local\Programs\Python\Python310\lib\requests\sessions.py”, line 573, in request
prep = self.prepare_request(req)
File “C:\Users\heino\AppData\Local\Programs\Python\Python310\lib\requests\sessions.py”, line 484, in prepare_request
File “C:\Users\heino\AppData\Local\Programs\Python\Python310\lib\requests\models.py”, line 369, in prepare
File “C:\Users\heino\AppData\Local\Programs\Python\Python310\lib\requests\models.py”, line 491, in prepare_headers
File “C:\Users\heino\AppData\Local\Programs\Python\Python310\lib\requests\utils.py”, line 1037, in check_header_validity
raise InvalidHeader(
requests.exceptions.InvalidHeader: Header part (1659878019912117) from {‘ACCESS_NONCE’: 1659878019912117} must be of type str or bytes, not <class ‘int’>

Process finished with exit code 1

Hello @haka! Thank you for taking an interest in trying out Coinbase APIs. For the details regarding your concern, we will check on this for you with our team. We will get back to you once we have more information. Keep in touch!

1 Like

Hi @haka! Thank you for your continued support in using Coinbase APIs.
Regarding your inquiry, we suggest you check the Signature Examples in our documentation. From there, you can find an example that demonstrates how to generate a signature in Python. Additionally, we may not be able to provide support on Unofficial Libraries since these have not been security tested by Coinbase.

1 Like

Hi @danpaolo.ballares ,
thanks for your response. Is there an official python library? The links to libraries in your documentation are all unofficial. The only offical one I found and where the examples in your documentation seem to refer to (GitHub - coinbase/coinbase-python: DEPRECATED — Coinbase Python API), is deprecated. Some funcions in there work, other, e.g. client.get_accounts(), don’t.

Hi @haka ! Unfortunately, we do not have an official and actively maintained python library. Thanks for understanding!