title: AttributeError: 'NoneType' object has no attribute 'encode' (Binance)
body: <p>I expect this simple script that connects to Binance and gets the details of my account to work using <a href="https://github.com/sammchardy/python-binance" rel="nofollow noreferrer">python-binance</a> library (version: 0.7.9) out of the box but it does not seem to. I am able to connect to the API and get the price of bitcoin therefore I am confident the error is not this.</p>
  <pre class="lang-py prettyprint-override"><code>import os
  
  from binance.client import Client
  from binance.websockets import BinanceSocketManager
  from twisted.internet import reactor
  
  # Get keys
  api_key = os.environ.get('binance_api')
  api_secret = os.environ.get('binance_secret')
  
  # Connect to Binance
  client = Client(api_key, api_secret)
  print(client.get_account())
  
  </code></pre>
  <p>gives the following error.</p>
  <pre><code>---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-4-9c56ae96674c&gt; in &lt;module&gt;
  ----&gt; 1 print(client.get_account())
  
  ~/.local/lib/python3.8/site-packages/binance/client.py in get_account(self, **params)
     1765 
     1766         &quot;&quot;&quot;
  -&gt; 1767         return self._get('account', True, data=params)
     1768 
     1769     def get_asset_balance(self, asset, **params):
  
  ~/.local/lib/python3.8/site-packages/binance/client.py in _get(self, path, signed, version, **kwargs)
      235 
      236     def _get(self, path, signed=False, version=PUBLIC_API_VERSION, **kwargs):
  --&gt; 237         return self._request_api('get', path, signed, version, **kwargs)
      238 
      239     def _post(self, path, signed=False, version=PUBLIC_API_VERSION, **kwargs):
  
  ~/.local/lib/python3.8/site-packages/binance/client.py in _request_api(self, method, path, signed, version, **kwargs)
      200         uri = self._create_api_uri(path, signed, version)
      201 
  --&gt; 202         return self._request(method, uri, signed, **kwargs)
      203 
      204     def _request_withdraw_api(self, method, path, signed=False, **kwargs):
  
  ~/.local/lib/python3.8/site-packages/binance/client.py in _request(self, method, uri, signed, force_params, **kwargs)
      178             # generate signature
      179             kwargs['data']['timestamp'] = int(time.time() * 1000)
  --&gt; 180             kwargs['data']['signature'] = self._generate_signature(kwargs['data'])
      181 
      182         # sort get and post params to match signature order
  
  ~/.local/lib/python3.8/site-packages/binance/client.py in _generate_signature(self, data)
      133         ordered_data = self._order_params(data)
      134         query_string = '&amp;'.join([&quot;{}={}&quot;.format(d[0], d[1]) for d in ordered_data])
  --&gt; 135         m = hmac.new(self.API_SECRET.encode('utf-8'), query_string.encode('utf-8'), hashlib.sha256)
      136         return m.hexdigest()
      137 
  
  AttributeError: 'NoneType' object has no attribute 'encode'
  </code></pre>
  <p>Checking the <a href="https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#account-information-user_data" rel="nofollow noreferrer">docs</a>, I don't see what I might be doing wrong. Since the debug logs indicate the error might be in the binance api but I'm not sure because this is a basic feature and should work without any trouble.</p>
  <p>I appreciate your help.</p>