title: coinbase api invalid signature error python on get request
body: <p>trying to view my listed accounts in coinbase and I've generated my hmac hash and got no errors however for some reason I'm still getting <code>{'message': 'invalid signature'}</code> and a 401 error, I even tried to make a new key in coinbase to make sure that wasn't the issue</p>
  <p>here is my code for reference I'm just starting out so I have very little to show, I'm trying to make a barebones version of the api documentation shown here <a href="https://docs.pro.coinbase.com/#signing-a-message" rel="nofollow noreferrer">https://docs.pro.coinbase.com/#signing-a-message</a></p>
  <p>I have checked to make sure my api key is enabled and has proper access to the coinbase api, but honestly the documentation definitely could use some work as I've seen a lot of unanswered questions similar to this on stack and github and I think some things have been left out, I am also turning my signed hash to lowercase below as that was recommended in another post</p>
  <pre class="lang-py prettyprint-override"><code>
  def get_accounts(self):
          print(&quot;getting accounts&quot;)
          secret = bytes(self.secret, 'UTF-8')
  
          #unicode objects must be encoded before hashing?? what is that??
          timestamp = str(time.time())
          message = timestamp + 'GET' + self.baseurl + 'accounts' + ''
          message = bytes(message, 'UTF-8')
        
          hmac_key = base64.b64decode(secret)
          signature = hmac.new(hmac_key, message, hashlib.sha256)
          signature = signature.hexdigest()
          print('signature',signature)
       
  
          #final base 64 byte string to send, but we probably need a regular string
          signature_b64 = base64.b64encode(bytes(signature, 'UTF-8'))
          signature_b64 = signature_b64.decode(&quot;utf-8&quot;) 
          
          print('final',signature_b64.lower())
  
          headers = {
              'CB-ACCESS-SIGN': signature_b64.lower(),
              'CB-ACCESS-TIMESTAMP': timestamp,
              'CB-ACCESS-KEY': self.key,
              'CB-ACCESS-PASSPHRASE': self.passphrase,
              'Content-Type': 'application/json'
          }
         
          r = requests.get(self.baseurl + 'accounts', headers=headers)
          print (r.status_code)
          print( r.json())
  </code></pre>