title: Generate HMAC Sha256 in python 3
body: <p>I write code to verify an HMAC Auth incoming POST request with JSON to our API. The HMAC I received is <code>OD5ZxL4tdGgWr78e9vO3cYrjuOFT8WOrTbTIuuIH1PQ=</code></p>
  
  <p>When I try to generate it by my self using Python, it is always different.</p>
  
  <p>Here is the JSON request I received:</p>
  
  <pre><code>{
      "shipper_id": 4841,
      "status": "Cancelled",
      "shipper_ref_no": "",
      "tracking_ref_no": "",
      "shipper_order_ref_no": "",
      "timestamp": "2018-05-23T15:13:28+0800",
      "id": "61185ecf-3484-4985-b625-ffe30ba36e28",
      "previous_status": "Pending Pickup",
      "tracking_id": "NVSGBHINK000000001"
  }
  </code></pre>
  
  <p>And the client secret is <code>817a3723917f4c7fac24b1f1b324bbab</code>.</p>
  
  <p>The HMAC secret I received is <code>OD5ZxL4tdGgWr78e9vO3cYrjuOFT8WOrTbTIuuIH1PQ=</code>.</p>
  
  <p>Here is the code when I write it in PHP: </p>
  
  <pre><code>&lt;?php
  define('CLIENT_SECRET', 'my_shared_secret');
  function verify_webhook($data, $hmac_header){
      $calculated_hmac = base64_encode(hash_hmac('sha256', $data, CLIENT_SECRET, true));
      return ($hmac_header == $calculated_hmac);
  }  
  $hmac_header = $_SERVER['X-NINJAVAN-HMAC-SHA256'];
  $data = file_get_contents('php://input');  
  $verified = verify_webhook($data, $hmac_header);
  error_log('Webhook verified: '.var_export($verified, true)); //check error.log to see result
  ?&gt;
  </code></pre>
  
  <p>But I have no idea how to do it in Python 3.</p>