title: python HTTP request is not working properly
body: <p>So I am trying to code that registers an account on a squarespace website. I fired up Fiddler and intercept the HTTP requests, saw the <code>POST</code> request that sends the form data:</p>
  
  <p><img src="https://i.stack.imgur.com/8BBSK.png" alt=""></p>
  
  <p>so I wrote this code in Python: </p>
  
  <pre><code>import requests
  
  session = requests.session()
  
  data = {
      'firstName': 'joe',
      'lastName': 'channel',
      'accountLoginOrigin': 'signup',
      'password': 'pass12345',
      'confirmPassword': 'pass12345',
      'email': 'flff30@mxi_w.com'
  }
  
  r = session.post('http://miniview.squarespace.com/api/site-users/account/profile', data=data,verify=False)
  r.text
  
  u'{"message":"User must be logged in to access this resource."}
  </code></pre>
  
  <p>What's my mistake with this Python request?</p>
  
  <p>It's strange because I'm expected to be logged before I can register.</p>
  
  <p>Edit:</p>
  
  <p>The first person that answered me said i should look into the cookies which i did, now i am trying to manually add cookies to the request session cookieJar but something is unclear to me. This request</p>
  
  <pre><code>POST https://minnicow.squarespace.com/api/census/RecordHit HTTP/1.1
  Host: minicow.squarespace.com
  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0
  Accept: application/json, text/plain, */*
  Accept-Language: en-US,en;q=0.5
  Accept-Encoding: gzip, deflate, br
  Content-Type: application/x-www-form-urlencoded; charset=utf-8
  X-CSRF-Token: BToh7ecmmp4cYzg0YjI3OTQ3MjI5Nzk1MGE2ZWZkZTQ1OTQwOTIw
  Content-Length: 741
  Origin: https://minicow.squarespace.com
  DNT: 1
  Connection: keep-alive
  Referer: https://minicow.squarespace.com/
  Cookie: crumb=BToh7ecmmp4cYzg0YjI3OTQ3MjI5Nzk1MGE2ZWZkZTQ1OTQwOTIw; ss_cvr=014571ee-fb3f-498c-b2a0-a9b5c470f9af|1576941479208|1576941479208|1576941479208|1; ss_cvt=1576941479208
  
  event=1&amp;data=%7B%22localStorageSupported%22%3Atrue%2C%22queryString%22%3A%22%22%2C%22referrer%22%3A%22%22%2C%22websiteId%22%3A%225dfd4479a068b47518c09b20%22%2C%22templateId%22%3A%225c5a519771c10ba3470d8101%22%2C%22website_locale%22%3A%22en-US%22%2C%22userAgent%22%3A%22Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64%3B%20rv%3A71.0)%20Gecko%2F20100101%20Firefox%2F71.0%22%2C%22clientDate%22%3A1576941479207%2C%22viewportInnerHeight%22%3A790%2C%22viewportInnerWidth%22%3A1536%2C%22screenHeight%22%3A864%2C%22screenWidth%22%3A1536%2C%22url%22%3A%22%2F%22%2C%22title%22%3A%22Home%22%2C%22collectionId%22%3A%225dfd45313ef7d373d3d9a389%22%7D&amp;ss_cvr=014571ee-fb3f-498c-b2a0-a9b5c470f9af%7C1576941479208%7C1576941479208%7C1576941479208%7C1
  </code></pre>
  
  <p>responds with this </p>
  
  <pre><code>HTTP/1.1 200 OK
  date: Sat, 21 Dec 2019 15:18:08 GMT
  strict-transport-security: max-age=0
  set-cookie: ss_cid=40ec759f-0ef6-4c31-a7c8-d8c1f2127d8a; Path=/; Expires=Mon, 20-Dec-2021 15:18:09 GMT; Max-Age=63072000
  expires: Thu, 01 Jan 1970 00:00:00 GMT
  set-cookie: ss_cvisit=1576941489288; Path=/; Expires=Sat, 21-Dec-2019 15:48:09 GMT; Max-Age=1800
  set-cookie: ss_cpvisit=1576941489288; Path=/; Expires=Mon, 20-Dec-2021 15:18:09 GMT; Max-Age=63072000
  content-type: application/json;charset=utf-8
  x-content-type-options: nosniff
  transfer-encoding: chunked
  x-contextid: kpeBSI9l/GOyKGPyu
  server: Squarespace
  
  11
  {"success": true}
  0
  </code></pre>
  
  <p>I.e three new cookies are set (ss_cid, ss_cvisit and ss_cpvisit) .. when i tried to recreate this request in python requests, i get the same success message in the response body but these 3 new cookies are not being set. </p>
  
  <p>Then i noticed that the request header contains three cookies - i was able to set the first one  (crub cookie), but  could not figure out how the other two cookies (ss_cvr and ss_cvt ) are being set.</p>
  
  <p>I checked the whole fiddler log right from where the page is loaded to the point where this request is made, i could not find where they are set. I also search their values in the preceding responses i couldn't find them, while ss_cvt looks like Epoch form of the time was made while ss_cvr hasthe  form "UUID()|ss_cvt|ss_cvt|ss_cvt|1" . i tried generating and substituting those values in the request but nothing works.</p>
  
  <p>I am trying to get this to work, but it is obvious that i need help</p>