title: Parsing data via API with Python. Bearer tokens
body: <p>I’m trying to build a project, where prog automatically parses data file from API, perform calculations and returns me some output. And I find myself stuck with parsing data from API. So, the website, which I’m trying to access, says next:</p>
  <pre><code>    **Authentication and API Token
      USDA ESMIS provides the api-token to all users. Once you have created and confirmed your account, you can request the api-token by making a POST request to /user-token.
  
      A curl request to get the api-token:
      curl -X POST &quot;https://usda.library.cornell.edu/user_token&quot; -d '{&quot;auth&quot;: {&quot;email&quot;:&quot;john.smith@example.com&quot;,&quot;password&quot;:&quot;password&quot;}}' -H &quot;Content-Type: application/json&quot;
      
  Authorization and API Requests
      To access the API, all requests need an api-token to be passed in the Authorization request header as a bearer token.
      
  Authorization: Bearer api-token
      You can also get the api-token below using the POST request to /user_token. Use the api-token with the Authorize feature on this page to test the API.**
  </code></pre>
  <p>The <a href="https://usda.library.cornell.edu/apidoc/index.html#/account/getUserToken" rel="nofollow noreferrer">link to the full text</a>.</p>
  <p>I’m transforming the curl request into:</p>
  <pre><code>import requests
  
  headers = {
   'accept': '*/*',
   'Content-Type': 'multipart/form-data:',
  }
  
  data = '{auth[email]:aaaa,auth[password]:aaaaaa}'
  
  response = requests.post('https://usda.library.cornell.edu/user_token', headers=headers, data=data)
  </code></pre>
  <p>But getting only 400 error. As far as I understand the problem is in Bearer tokens. I’ve tried to find some FAQ’s or tutorials on this topic but without luck. Can you, please, advise in general what I need to know to parse data via API with Python with such tokens and recommend some resources to learn about it?</p>