title: Chrome Web Push Notification with Encrypted Payload in Python
body: <p>Can someone please explain how to send Web Push Notification with Payload for Chrome using Curl/Python ?</p>
  
  <p>This is the code I am trying: </p>
  
  <p>Code: </p>
  
  <pre><code>fcm_url = "https://fcm.googleapis.com/fcm/send"
  headers = {'Content-Type': 'application/json'}    
  headers.update({'Authorization': 'key=' + fcm_key})
  
  encoded = {'body': "i\x87\xb7W\xee\xd6QzL\xb6Q\xfe\xf5=t\xc4D[\xfe\xe3+g\xb7\x86\xdd\x81\xb9I\xffX\x99\x9b\x85$x\x80\xc6\x88\xe3\xbcm\x91\xff\x17a\x87C\x81\xf0\xbd\xb3}Y\xc8\xdb:\x14\x02\xf2R\xe7\x12\xcb\x1c\x0f\x13\xca'\xec7B\xc3\x9e\xb2\x17\xa0\xf0\xcd\xed3\xff\x1e\xc9k'A\xfb\x84\xf0\x17\xd4+I\xe0\xe0\x92i%\x00\xf0\xe0\xdb[\xa5\xc9/'\xc3L\xf6a\x183\xc1x7\xa6\x04!\xcctH\xf3\xf3\xcf\xf5\x12r\xd3\xf4\xd4\x8b\x10pc\x84Dd\xee\xe5'\x82\xa8\x81\x9a\xf4\x94\xd3\x12\x166\x91G3t\x08\xf9\xbe\x1b\x90\x02\xc6\x17\x17\xc3\xe9\x08qQK\xd4\xce\xc2\x88\x8f\xcbA\xc9\xfd]\x99\x13\xfd\xa6v2\xd65\x1b\xd5\x82)FUX\x92c\xed\xecF\x91rk\xba\x04\xd2\x90\x93a\n\x96|M}\x10\xc4\xb0\xe4\xdd\x1dd4\xf1\xcb\x06&lt;\xf7\x06\xf9\xfe\xce\x19W\xaa\xc4", 'crypto_key': 'BJUZv_0v3lqIkptS5R4r-DKbVXl4Cpd4YN4ASO4dcNzEGPgtNW7EDF2HBSNGy0fI8kBJj3bnSuCh0bmR46ICKpc', 'salt': 'bjNe7m6zIQeDcsh4TF_wqg'}
  
  crypto_key = "dh=" + encoded["crypto_key"]
  salt = "salt=" + encoded['salt']
  headers.update({'crypto-key': crypto_key, 'content-encoding': 'aesgcm', 'encryption': salt})    
  fcm_data = {"data": {"message": base64.urlsafe_b64encode(encoded['body'])}, "registration_ids": google_ids_array}
  resp = requests.post(fcm_url, data=json.dumps(fcm_data), headers=headers)
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>(200, 'OK')
  {"multicast_id":66796434737498,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:14768189819%063a1cbcf9fd7ecd"}]}
  </code></pre>
  
  <p>but the notification doesn't contain the above specified Data.</p>
  
  <p>Cases Tried, But None Useful: </p>
  
  <pre><code>1) fcm_data = {"data": {"message": "Hello"}, "to": google_ids_array[0]} # Wrong Notification
  2) fcm_data = {"data": {"message": "Hello"}, "registration_ids": google_ids_array} # Wrong Notification
  3) fcm_data = {"data": {"message": base64.urlsafe_b64encode(encoded['body'])}, "to": google_ids_array[0]} # Wrong Notification
  4) fcm_data = {"data": {"message": base64.urlsafe_b64encode(encoded['body'])}, "registrations_ids": google_ids_array} # Bad Request, to
  
  5) fcm_data = {"raw_data": "He", "registration_ids": google_ids_array} # success, No Notification
  6) fcm_data = {"raw_data": str({"message": "Hello"}), "registration_ids": google_ids_array} # Failure, MessageTooBig
  7) fcm_data = {"raw_data": base64.urlsafe_b64encode(encoded['body']), "registration_ids": google_ids_array} # Failure, MessageTooBig
  </code></pre>
  
  <p>Can someone please suggest how to send correct Web Notification with Payload on Chrome Browser ? </p>
  
  <p>Any Suggestion/Hint would be helpful...</p>
  
  <p>Thanks,</p>