question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error : Web push send from python backend to fire base using VAPI keys. Unhashable type:'slice'

See original GitHub issue

I have trouble getting pywebpush work for my python backend on gcp.

VAPI PUBLIC KEY and PVT KEY obtained from firebase dash board thourhg manual creation

#subscriptionObject comes from Angular front end. It used the VAPI PUBLIC KEY to receive the object. I used the package versions specified in requirement.txt. The call happens from a Flask app route.

webpush(subscription_info = subscriptionObject, data=notificationMessageObject, vapid_private_key=VAPID_PRIVATE_KEY, vapid_claims={"sub": "mailto:mycontact_supplied_at_fire_base_bashboard@mydomain.com"}) Error Traceback (most recent call last): File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 2292, in wsgi_app response = self.full_dispatch_request() File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File “/usr/local/lib/python3.7/site-packages/flask_cors/extension.py”, line 110, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File “/usr/local/lib/python3.7/site-packages/flask/_compat.py”, line 35, in reraise raise value File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1813, in full_dispatch_request rv = self.dispatch_request() File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1799, in dispatch_request return self.view_functionsrule.endpoint File “/app/main.py”, line 428, in notify_one_device webpush(subscription_info = subsObject, data=notificationMessageObject, vapid_private_key=VAPID_PRIVATE_KEY, vapid_claims={“sub”: “mailto:mymail_configured_at_firebase_dashboard@mycontact.com”}) File “/usr/local/lib/python3.7/site-packages/pywebpush/init.py”, line 485, in webpush timeout=timeout, File “/usr/local/lib/python3.7/site-packages/pywebpush/init.py”, line 305, in send encoded = self.encode(data, content_encoding) File “/usr/local/lib/python3.7/site-packages/pywebpush/init.py”, line 219, in encode version=content_encoding) File “/usr/local/lib/python3.7/site-packages/http_ece/init.py”, line 394, in encrypt content[i:i + chunk_size], TypeError: unhashable type: ‘slice’

Please guide how I should approach this.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ishwara-bhatcommented, Aug 24, 2022

For web push alone, I went for nodejs service. Rest of my back end is in python.

On Tue, 23 Aug 2022, 22:31 Carlos Mesas, @.***> wrote:

@ishwara-bhat https://github.com/ishwara-bhat I have the same problem, how could you solve it?

— Reply to this email directly, view it on GitHub https://github.com/web-push-libs/pywebpush/issues/145#issuecomment-1224351178, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJVKQPG2UZOTIDACENMTB7TV2T7VFANCNFSM5KJFSGGQ . You are receiving this because you were mentioned.Message ID: @.***>

0reactions
cmesascommented, Aug 24, 2022

Las claves de cadena pueden estar en formato raw o DER: https://github.com/web-push-libs/vapid/blob/main/python/py_vapid/__init__.py#L134-L147 . Si proporciona una ruta, py_vapid intentará leer el archivo con formato PEM o DER https://github.com/web-push-libs/vapid/blob/main/python/py_vapid/__init__.py#L134-L147

Ok, I will try to work with the private key in PEM format from the file directly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python issue: TypeError: unhashable type: 'slice' during web ...
When I run this, I get a 403 error from the web server, which of course means the soup ends up empty, results...
Read more >
Python TypeError: unhashable type: 'slice' Solution
The “TypeError: unhashable type: 'slice'” error is raised when you try to access items from a dictionary using slicing syntax. To solve this...
Read more >
[Solved] TypeError: Unhashable Type: 'slice' - Python Pool
Python compares dictionary keys with hash values while working with dictionary elements. We can hash strings or integers but cannot slice them.
Read more >
Predict-tags-on-StackOverflow/test.tsv at master - GitHub
How to use remote server sqlite database using python? Java's setPreferredSize won't resize JPanel. Block a certain website using java. HttpClient and ......
Read more >
sitemap.xml - Intellipaat
https://intellipaat.com/community/3/git-push-vs-git-push-origin ... .com/community/736/pip-install-unroll-python-setup-py-egginfo-failed-with-error-code-1 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found