-
Notifications
You must be signed in to change notification settings - Fork 113
Error 400 UnauthorizedRegistration #46
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
Comments
If you are using VAPID you should configure the public- and private key. The spring-boot-web-push repository contains an example on how to invoke the web push library. Specifically, line 27 of SendController.java configures the |
@martijndwars I call the |
May be a duplicate of Issue 33. |
@johanvs can you create a minimal reproducible example (e.g. in a git repository)? If you follow the steps outlined in spring-boot-web-push, does it work? |
Thanks a lot @martijndwars. thanks to your example I understood what was wrong with my code. After tests of changing keys, I did not updated the public key in the javascript file, and it was different from the server one. Now it works :-) |
@martijndwars we are facing the same error while we use GCM key (we can successfully send most of the notifications, but for some we are getting this error) , any thoughts what may cause the problem? |
Hi @ihalilaltun, things you could try:
|
Hi @martijndwars, I do not try to re-send them, as indicated in documentation I am deleting these users :/ . I'll try re-sending to these users, but other than this do you have anything else in your mind to check? |
That code uses private key, public key and subject as parameters to create the PushService. When I ran web-push generate-vapid-keys command I only get the keys (angular tutorial available here - see "Generating a VAPID key pair using node web-push"). There is no subject (neither an input from me nor an output from the command). Do you have any suggestion on how to generate a key pair with subject or which subject I pass as a parameter ? Thanks |
The subject parameter is part of the VAPID specification, but it's value is not really important. According to the specification:
An example subject would be |
Thanks for your response. But I'm still facing the same unauthorized error. My code is the same as above (original code posted by dyogomedeiros), except that I'm using the PushService constructor that receives public key, private key and subject as strings. Those are the same in the server and in the client. I really don't know what I'm missing. Can you help me, please? Thanks |
I was sending the endpoint incorrectly, and that's why I got an unauthorized error. Now I get a 201 - Created result, but I can't see the actual notification in my ubuntu and chrome. What are the response error code meanings for this service? 201 I believe it is "ok", right? |
I figured it out: the payload cannot be a string like the one in the above code. It must be a json in a certain format. At least: { "notification": {"title": "message title", "body": "message body"} } Now it is ok! |
For the web push protocol the payload is just binary data. The The Push Event page describes several ways in which your service worker can parse the data:
|
You're right. We are using an angular service worker that expects json and does not handle well format errors. Thanks for the help! |
I am running into a similar issue, and am wondering if I can get some help. I got my push notifications to work on Firefox, but not on chrome. I was getting the 400 Unauthorized error like the users above. I was originally not using VAPID, but wondered if I needed to be. Following the advice of @martijndwars, I added my VAPID private and public key-pair to the backend (based on this comment):
However I am now getting a 403 forbidden instead. Firefox still working as expected. I'm not using GCM, just trying to do it myself. Is there something I'm missing/ doing wrong here? Currently using version 5.0.1. |
Scratch that! I got it to work, I just needed to un-register and re-register the service worker after adding the My comment now becomes, that I needed to do a lot of googling and investigating to get to this point and get it working. I needed to find this thread specifically and use the example from https://github.com/MartijnDwars/spring-boot-web-push instead of the one from the Usage example in the wiki: https://github.com/web-push-libs/webpush-java/wiki/Usage-Example , I'm wondering if it might be of use to people who end up in a similar situation as me to update the wiki accordingly. |
I'm glad you got this to work @dsteen338! I'd be happy to discuss ideas that could improve the wiki. PRs that improve the documentation are very welcome. It seems that most comments on this issue are about problems with using the library and not with the library itself, so I will close the issue now. If someone bumps into a similar issue or wants to discuss improvements to the documentation, please create a new issue. |
I use this code:
And receive this answer:
The text was updated successfully, but these errors were encountered: