title: bad request error 400
body: <p>I want to replicate the below with Client config.</p>
  
  <pre><code>Curl -D- -X GET -H "Authorization: Basic ZnJlZDpmcmVk" -H "Content-Type: application/json" http://localhost:7990/rest/api/1.0/projects
  https://developer.atlassian.com/server/bitbucket/how-tos/example-basic-authentication/
  </code></pre>
  
  <p>This is to download a file for updating exe in a private repo.</p>
  
  <p>I'm getting 400 errors on a regular basis with bitbucket.  </p>
  
  <p>What I had:</p>
  
  <pre><code>client = Client(ClientConfig(), headers={'basic_auth':'U:P' }, refresh=True)
  </code></pre>
  
  <p>I want to include this header</p>
  
  <pre><code>header = {'Content-Type': 'application/json'}
  </code></pre>
  
  <p>So something like:</p>
  
  <pre><code>client = Client(ClientConfig(), headers={'basic_auth': 'brofewfefwefewef:EKAXsWkdt5H6yJEmtexN'}, header = {'Content-Type': 'application/json'}, refresh=True)
  </code></pre>
  
  <p>Should fix?</p>
  
  <p>At least according to....</p>
  
  <p>"Some http client software expects to receive an authentication challenge before it will send an authorization header and this may mean that it may not behave as expected. In this case you may need to configure it to supply the authorization header as described above rather than relying on its default mechanism."</p>
  
  <p>and...</p>
  
  <pre><code>https://stackoverflow.com/questions/8840303/urllib2-http-error-400-bad-request
  </code></pre>
  
  <p>For me though, I always get error even with this change 400 <a href="https://pastebin.com/V9ibxTRX" rel="nofollow noreferrer">https://pastebin.com/V9ibxTRX</a> (full code here or short version below) </p>
  
  <p>Optional errors message (it's not pretty but I did reduce it):</p>
  
  <pre><code>~~~~~ACCESSING PAGE AND FOUND!~~~
  DEBUG:pyupdater.client.downloader:Url for request: https://api.bitbucket.org/2.0/repositories/Username/repository/downloads/keys.gz
  DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.bitbucket.org
  send: b'GET /2.0/repositories/Username/repository/downloads/keys.gz HTTP/1.1\r\nHost: api.bitbucket.org\r\nAccept-Encoding: identity\r\nauthorization: Basic ywafdwafawffwawffawafwfwaawfawfg==\r\n\r\n'
  reply: 'HTTP/1.1 302 Found\r\n'
  
  ~~~~~~RETRYING REDIRECTION PRESENT (IS THIS THE CAUSE OF ISSUES)??~~
  DEBUG:urllib3.connectionpool:https://api.bitbucket.org:443 "GET /2.0/repositories/Username/repository/downloads/keys.gz HTTP/1.1" 302 0
  DEBUG:urllib3.util.retry:Incremented Retry for (url='https://api.bitbucket.org/2.0/repositories/Username/repository/downloads/keys.gz'): Retry(total=2, connect=None, read=None, redirect=None, status=None)
  INFO:urllib3.poolmanager:Redirecting https://api.bitbucket.org/2.0/repositories/Username/repository/downloads/keys.gz -&gt; https://bbuseruploads.s3.amazonaws.com/a0e395b6-0c54-4efb-9074-57ec4190020b/downloads/1c87431a-98de-4d97-8c80-000243f81cba/keys.gz?Signature=FvA9X7K9ryM2Ft2mTV7PZefidJY%3D&amp;Expires=1515817377&amp;AWSAccessKeyId=AKIAIQWXW6WLXMB5QZAQ&amp;versionId=6J830UBC1RFvWz.R6pMDwIiJQNKJjSkm&amp;response-content-disposition=attachment%3B%20filename%3D%22keys.gz%22
  
  DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): bbuseruploads.s3.amazonaws.com
  
  ~~HEADERS MIGHT BE ISSUE ACCORDING TO DOCS  https://developer.atlassian.com/server/bitbucket/how-tos/example-basic-authentication/~~
  
  header: Server header: Vary header: Content-Type header: X-OAuth-Scopes header: Strict-Transport-Security header: Date header: Location header: X-Served-By header: ETag header: X-Static-Version header: X-Content-Type-Options header: X-Accepted-OAuth-Scopes header: X-Credential-Type header: X-Render-Time header: Connection header: X-Request-Count header: X-Frame-Options header: X-Version header: Content-Length send: b'GET /a0e395b6-0c54-4efb-9074-57ec4190020b/downloads/1c87431a-98de-4d97-8c80-000243f81cba/keys.gz?Signature=FvA9X7K9ryM2Ft2mTV7PZefidJY%3D&amp;Expires=1515817377&amp;AWSAccessKeyId=AKIAIQWXW6WLXMB5QZAQ&amp;versionId=6J830UBC1RFvWz.R6pMDwIiJQNKJjSkm&amp;response-content-disposition=attachment%3B%20filename%3D%22keys.gz%22 HTTP/1.1\r\nHost: bbuseruploads.s3.amazonaws.com\r\nAccept-Encoding: identity\r\nauthorization: Basic YnJvZmV3ZmVmd2VmZXdlZjpFS0FYc1drZHQ1SDZ5SkVtdGV4Tg==\r\n\r\n'
  DEBUG:urllib3.connectionpool:https://bbuseruploads.s3.amazonaws.com:443 "GET /a0e395b6-0c54-4efb-9074-57ec4190020b/downloads/1c87431a-98de-4d97-8c80-000243f81cba/keys.gz?
  Signature=FvA9X7K9ryM2Ft2mTV7PZefidJY%3D&amp;Expires=1515817377&amp;AWSAccessKeyId=AKIAIQWXW6WLXMB5QZAQ&amp;versionId=6J830UBC1RFvWz.R6pMDwIiJQNKJjSkm&amp;response-content-disposition=attachment%3B%20filename%3D%22keys.gz%22 HTTP/1.1" 400 None
  
  ~~UNABLE TO ACCESS PAGE (WAIT, BEFORE IT HAD 'HTTP/1.1 302 Found\r\n' SEE TOP)~~
  reply: 'HTTP/1.1 400 Bad Request\r\n'
  
  DEBUG:pyupdater.client.downloader:Resource URL: https://api.bitbucket.org/2.0/repositories/Username/repository/downloads/keys.gz
  DEBUG:pyupdater.client.downloader:Got content length of: None
  DEBUG:pyupdater.client.downloader:Content-Length not in headers
  DEBUG:pyupdater.client.downloader:Callbacks will not show time left or percent downloaded.
  DEBUG:pyupdater.client.downloader:Using file as storage since the file is too large
  </code></pre>