title: Why does Bearer not work in requests authorization header?
body: <p>I'm having a problem sending an authorization token with Bearer to NEST API via python requests:</p>
  
  <pre><code>curl https://developer-api.nest.com -H "Authorization: Bearer c.123"
  -H "Content-Type: application/json"
  </code></pre>
  
  <p>works fine, however:</p>
  
  <pre><code>nest_url = "https://developer-api.nest.com"
  headers = {'Authorization': str('Bearer ' + token), 'Content-type': 'application/json'}
  print(headers)
  nest_data_req = requests.get(nest_url, headers=headers)
  </code></pre>
  
  <p>which prints as:</p>
  
  <blockquote>
    <p>{'Content-type': 'application/json', 'Authorization': 'Bearer c.123'}</p>
  </blockquote>
  
  <p>fails with a 401 unauthorized, as far as I can tell they are trying to make the same request so why does curl work (and postman for that matter) and python requests fail?</p>
  
  <p>The following image shows the same working in postman:</p>
  
  <p><a href="https://i.stack.imgur.com/Kdh8N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kdh8N.png" alt="enter image description here"></a>
  Update:</p>
  
  <p>So this code works 1 in 10 times (the other 9+ give me 401 unauthorized):</p>
  
  <pre><code> url = "https://developer-api.nest.com/"
      auth_t = token.encode("ascii", "ignore")
      headers = {
          'authorization': "Bearer " + auth_t,
          'content-type': "application/json",
          'cache-control': "no-cache",
      }
      response = requests.request("GET", url, headers=headers)
      print(response.text)
  </code></pre>
  
  <p>if I press submit in postman it works everytime without fail.</p>