Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ easier.

```pythonstub
from pywebpush import webpush
from urllib.parse import urlparse

endpoint_parsed = urlparse(subscription_info["endpoint"])
audience = "%s://%s" % (endpoint_parsed.scheme, endpoint_parsed.hostname)

webpush(subscription_info,
data,
vapid_private_key="Private Key or File Path[1]",
vapid_claims={"sub": "mailto:YourEmailAddress"})
vapid_claims={"sub": "mailto:YourEmailAddress", "aud": audience})
```
This will encode `data`, add the appropriate VAPID auth headers if required and send it to the push server identified
in the `subscription_info` block.
Expand Down Expand Up @@ -90,6 +94,7 @@ try:
vapid_private_key="path/to/vapid_private.pem",
vapid_claims={
"sub": "YourNameHere@example.org",
"aud": "https://push.example.com",
}
)
except WebPushException as ex:
Expand Down
7 changes: 6 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ recipients. There's a "One Call" function which will make things easier.
.. code:: pythonstub

from pywebpush import webpush
from urllib.parse import urlparse

endpoint_parsed = urlparse(subscription_info["endpoint"])
audience = "%s://%s" % (endpoint_parsed.scheme, endpoint_parsed.hostname)

webpush(subscription_info,
data,
vapid_private_key="Private Key or File Path[1]",
vapid_claims={"sub": "mailto:YourEmailAddress"})
vapid_claims={"sub": "mailto:YourEmailAddress", "aud": audience})

This will encode ``data``, add the appropriate VAPID auth headers if
required and send it to the push server identified in the
Expand Down Expand Up @@ -101,6 +105,7 @@ e.g. the output of:
vapid_private_key="path/to/vapid_private.pem",
vapid_claims={
"sub": "YourNameHere@example.org",
"aud": "https://push.example.com",
}
)
except WebPushException as ex:
Expand Down