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

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

@MichaelOhn

Description

@MichaelOhn

Hi,

After following the installation step from your readme file and trying to execute the following code:

import coinbase

coinbase_api_key    = str('<api_key>')
coinbase_api_secret = str('<api_secret_key>')
coinbase = coinbase.Coinbase.with_api_key(coinbase_api_key, coinbase_api_secret)
balance = coinbase.get_balance()
print('Balance is ' + balance + ' BTC')

I get the following exception:

python3 wallet-watcher.py Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/utils.py", line 868, in check_header_validity
    if not pat.match(value):
TypeError: expected string or bytes-like object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "wallet-watcher.py", line 7, in <module>
    balance = coinbase.get_balance()
  File "/usr/local/lib/python3.6/dist-packages/coinbase/__init__.py", line 138, in get_balance
    return self.get('/account/balance')['amount']
  File "/usr/local/lib/python3.6/dist-packages/coinbase/__init__.py", line 122, in get
    return self.__rpc.request('GET', path, params)
  File "/usr/local/lib/python3.6/dist-packages/coinbase/CoinbaseRPC.py", line 75, in request
    request = requests.get(url, headers=headers)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 506, in request
    prep = self.prepare_request(req)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 449, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/lib/python3/dist-packages/requests/models.py", line 306, in prepare
    self.prepare_headers(headers)
  File "/usr/lib/python3/dist-packages/requests/models.py", line 440, in prepare_headers
    check_header_validity(header)
  File "/usr/lib/python3/dist-packages/requests/utils.py", line 872, in check_header_validity
    "bytes, not %s" % (name, value, type(value)))
requests.exceptions.InvalidHeader: Value for header {ACCESS_NONCE: 1609705740747573} must be of type str or bytes, not <class 'int'>

System info:

Kernel: 4.19.25-041925-generic x86_64
bits: 64
Desktop: Gnome 3.28.4
Distro: Ubuntu 18.04.5 LTS

Could I have any advice of what I would be doing wrong ?

Best regards,

Mike O.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions