@@ -10,12 +10,12 @@ available on `github <https://github.com/mozilla-services/pywebpush>`__.
1010Installation
1111------------ 
1212
13- You' ll need to run ``python virtualenv ``. Then
13+ You’ ll need to run ``python virtualenv ``. Then
1414
1515::
1616
17-    bin/pip install -r requirements.txt 
18-    bin/python setup.py develop 
17+  bin/pip install -r requirements.txt 
18+  bin/python setup.py develop 
1919
2020Usage
2121----- 
@@ -31,94 +31,94 @@ As illustration, a ``subscription_info`` object may look like:
3131
3232.. code :: json 
3333
34-    {"endpoint" : " https://updates.push.services.mozilla.com/push/v1/gAA..." "keys" : {"auth" : " k8J..." "p256dh" : " BOr..."  
34+  {"endpoint" : " https://updates.push.services.mozilla.com/push/v1/gAA..." "keys" : {"auth" : " k8J..." "p256dh" : " BOr..."  
3535
3636
37- referenced to the user who requested it, and recall it when there' s a
37+ referenced to the user who requested it, and recall it when there’ s a
3838new push subscription update is left as an exercise for the reader.
3939
4040Sending Data using ``webpush() `` One Call
4141~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
4242
4343In many cases, your code will be sending a single message to many
44- recipients. There' s a " One Call"  function which will make things easier.
44+ recipients. There’ s a “ One Call”  function which will make things easier.
4545
4646.. code :: python 
4747
48-    from  pywebpush import  webpush 
48+  from  pywebpush import  webpush 
4949
50-    webpush(subscription_info, 
51-    data, 
52-    vapid_private_key = " Private Key or File Path[1]"  
53-    vapid_claims = {" sub" " mailto:YourEmailAddress"  
50+  webpush(subscription_info, 
51+  data, 
52+  vapid_private_key = " Private Key or File Path[1]"  
53+  vapid_claims = {" sub" " mailto:YourEmailAddress"  
5454
5555data ``, add the appropriate VAPID auth headers if
5656required and send it to the push server identified in the
5757``subscription_info `` block.
5858
5959**Parameters **
6060
61- *subscription \_ info dict `` of the subscription info (described
61+ *subscription_info * - The ``dict `` of the subscription info (described
6262above).
6363
6464*data * - can be any serial content (string, bit array, serialized JSON,
6565etc), but be sure that your receiving application is able to parse and
66- understand it. (e.g.  ``data = "Mary had a little lamb." ``)
66+ understand it. (e.g.  ``data = "Mary had a little lamb."``) 
6767
68- *content \_ type 
68+ *content_type * - specifies the form of Encryption to use, either 
6969``'aes128gcm' `` or the deprecated ``'aesgcm' ``. NOTE that not all User
7070Agents can decrypt ``'aesgcm' ``, so the library defaults to the RFC 8188
7171standard form.
7272
73- *vapid \_ claims dict `` containing the VAPID claims required for
73+ *vapid_claims * - a ``dict `` containing the VAPID claims required for
7474authorization (See
75- `py \_ vapid  https://github.com/web-push-libs/vapid/tree/master/python >`__
75+ `py_vapid  https://github.com/web-push-libs/vapid/tree/master/python >`__
7676for more details). If ``aud `` is not specified, pywebpush will attempt
7777to auto-fill from the ``endpoint ``.
7878
79- *vapid \_ private \_ key 
80- file,  or a string containing the DER representation. (See
81- `py \_ vapid  https://github.com/web-push-libs/vapid/tree/master/python >`__
79+ *vapid_private_key * - Either a path to a VAPID EC2 private key PEM file, 
80+ or a string containing the DER representation. (See
81+ `py_vapid  https://github.com/web-push-libs/vapid/tree/master/python >`__
8282for more details.) The ``private_key `` may be a base64 encoded DER
8383formatted private key, or the path to an OpenSSL exported private key
8484file.
8585
86- e.g.  the output of:
86+ e.g.  the output of:
8787
8888::
8989
90-    openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem 
90+  openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem 
9191
9292**Example **
9393
9494.. code :: python 
9595
96-    from  pywebpush import  webpush, WebPushException 
97- 
98-    try : 
99-    webpush( 
100-    subscription_info = { 
101-    " endpoint" " https://push.example.com/v1/12345"  
102-    " keys"  
103-    " p256dh" " 0123abcde..."  
104-    " auth" " abc123..."  
105-    }}, 
106-    data = " Mary had a little lamb, with a nice mint jelly"  
107-    vapid_private_key = " path/to/vapid_private.pem"  
108-    vapid_claims = { 
109-    " sub" " mailto:YourNameHere@example.org"  
110-    } 
111-    ) 
112-    except  WebPushException as  ex: 
113-    print (" I'm sorry, Dave, but I can't do that: {} " repr (ex)) 
114-    #  Mozilla returns additional information in the body of the response. 
115-    if  ex.response and  ex.response.json(): 
116-    extra =  ex.response.json() 
117-    print (" Remote service replied with a {} :{} , {} "  
118-    extra.code, 
119-    extra.errno, 
120-    extra.message 
121-    ) 
96+  from  pywebpush import  webpush, WebPushException 
97+ 
98+  try : 
99+  webpush( 
100+  subscription_info = { 
101+  " endpoint" " https://push.example.com/v1/12345"  
102+  " keys"  
103+  " p256dh" " 0123abcde..."  
104+  " auth" " abc123..."  
105+  }}, 
106+  data = " Mary had a little lamb, with a nice mint jelly"  
107+  vapid_private_key = " path/to/vapid_private.pem"  
108+  vapid_claims = { 
109+  " sub" " mailto:YourNameHere@example.org"  
110+  } 
111+  ) 
112+  except  WebPushException as  ex: 
113+  print (" I'm sorry, Dave, but I can't do that: {} " repr (ex)) 
114+  #  Mozilla returns additional information in the body of the response. 
115+  if  ex.response and  ex.response.json(): 
116+  extra =  ex.response.json() 
117+  print (" Remote service replied with a {} :{} , {} "  
118+  extra.code, 
119+  extra.errno, 
120+  extra.message 
121+  ) 
122122
123123
124124~~~~~~~ 
@@ -145,13 +145,13 @@ Send the data using additional parameters. On error, returns a
145145*ttl * Message Time To Live on Push Server waiting for the client to
146146reconnect (in seconds)
147147
148- *gcm \_ key 
148+ *gcm_key * Google Cloud Messaging key (if using the older GCM push
149149system) This is the API key obtained from the Google Developer Console.
150150
151- *reg \_ id 
151+ *reg_id * Google Cloud Messaging registration ID (will be extracted from
152152endpoint if not specified)
153153
154- *content \_ encoding " aes128gcm" )
154+ *content_encoding * ECE content encoding type (defaults to “ aes128gcm” )
155155
156156*curl * Do not execute the POST, but return as a ``curl `` command. This
157157will write the encrypted content to a local file named
@@ -167,7 +167,7 @@ to send from Chrome using the old GCM mode:
167167
168168.. code :: python 
169169
170-    WebPusher(subscription_info).send(data, headers, ttl, gcm_key) 
170+  WebPusher(subscription_info).send(data, headers, ttl, gcm_key) 
171171
172172.encode(data, content_encoding="aes128gcm") ``
173173^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
@@ -179,19 +179,19 @@ Encode the ``data`` for future use. On error, returns a
179179
180180*data * Binary string of data to send
181181
182- *content \_ encoding " aes128gcm" )
182+ *content_encoding * ECE content encoding type (defaults to “ aes128gcm” )
183183
184184**Example **
185185
186186.. code :: python 
187187
188-    encoded_data =  WebPush(subscription_info).encode(data) 
188+  encoded_data =  WebPush(subscription_info).encode(data) 
189189
190190
191191------------------- 
192192
193- If you' re not really into coding your own solution, there' s also a
194- " stand-alone"  ``pywebpush `` command in the ./bin directory.
193+ If you’ re not really into coding your own solution, there’ s also a
194+ “ stand-alone”  ``pywebpush `` command in the ./bin directory.
195195
196196This uses two files: \*  the *data * file, which contains the message to
197197send, in whatever form you like. \*  the *subscription info * file, which
@@ -201,24 +201,24 @@ like:
201201
202202.. code :: json 
203203
204-    {"endpoint" : " https://push..."  
205-    "keys" : { 
206-    "auth" : " ab01..."  
207-    "p256dh" : " aa02..."  
208-    }} 
204+  {"endpoint" : " https://push..."  
205+  "keys" : { 
206+  "auth" : " ab01..."  
207+  "p256dh" : " aa02..."  
208+  }} 
209209
210- ' re interested in just testing your applications WebPush
210+ ’ re interested in just testing your applications WebPush
211211interface, you could use the Command Line:
212212
213213.. code :: bash 
214214
215-    ./bin/pywebpush --data stuff_to_send.data --info subscription.info 
215+  ./bin/pywebpush --data stuff_to_send.data --info subscription.info 
216216
217217stuff_to_send.data ``.
218218
219219See ``./bin/pywebpush --help `` for available commands and options.
220220
221- .. |Build Status | image :: https://travis-ci.org/web-push-libs/pywebpush.svg?branch=master  
221+ .. |Build Status | image :: https://travis-ci.org/web-push-libs/pywebpush.svg?branch=main  
222222 :target:  https://travis-ci.org/web-push-libs/pywebpush 
223- .. |Requirements Status | image :: https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=master  
224-  :target:  https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=master  
223+ .. |Requirements Status | image :: https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=main  
224+  :target:  https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=main  
0 commit comments