Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnauthorizedRegistration #30

Closed
PierrePaul opened this issue Dec 14, 2016 · 6 comments
Closed

UnauthorizedRegistration #30

PierrePaul opened this issue Dec 14, 2016 · 6 comments

Comments

@PierrePaul
Copy link

Im trying to use pywebpush under python 2.7 (and 3.5) without any success. I am getting the error UnauthorizedRegistration with a 400 response code. Using the Push Companion, everything works just fine (with the same key and same subscription info).

Also, my internal clock is synced (some people reported having issues if your clock is not synced).

My code :

from pywebpush import WebPusher
import json

sub = json.loads('{"endpoint":"https://fcm.googleapis.com/fcm/send/<redacted>","keys":{"p256dh":"<redacted>","auth":"<redacted>"}}')
r = WebPusher(sub).send(data='hey')

Which returns :

> r.text
u'<HTML>\n<HEAD>\n<TITLE>UnauthorizedRegistration</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>UnauthorizedRegistration</H1>\n<H2>Error 400</H2>\n</BODY>\n</HTML>\n'
> r.status_code
400

I am getting the same result no matter which Python version I use.
Any help debugging this would be really really appreciated...

@safwanrahman
Copy link
Collaborator

You should add the gcm_key like following
WebPusher(subscription_info).send(data, headers, ttl, gcm_key)

I have written some instruction in my package about sending notification to chrome users. You can take a look there

@PierrePaul
Copy link
Author

So I need to pass a gcm_key even if my endpoint does not start with android. ?

@safwanrahman
Copy link
Collaborator

I think it is needed for sending any notification via google cloud messaging channel

@PierrePaul
Copy link
Author

PierrePaul commented Dec 14, 2016

No luck, even with unrestricted API key :(

r = WebPusher(sub3).send(data="awdawd", gcm_key="<redacted>")

@jrconlin
Copy link
Member

If I understand google's FCM/WebPush protocol requirements: https://developers.google.com/web/updates/2016/07/web-push-interop-wins , you need to specify a VAPID header with your request. You would include the header as "Authorization: WebPush {JWK_token}". The article talks about how to create a VAPID header, and you may find https://github.com/web-push-libs/vapid/tree/master/python useful.

@jrconlin
Copy link
Member

jrconlin commented Jan 5, 2017

closing due to inactivity. If this is still a problem, please reopen with comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants