I've been doing a google tutorial on how to send web push notifications on Chrome using web-push node module.
The thing is, the tutorial also provides a companion server app that you are supposed to use in order to test sending push notifications from a server to the client.
But, in both the companion app and even when using web-push cli on my local machine, when trying to send a notification I am getting a "Unauthorized Registration" error. Can't find anything online about this error - what am I doing wrong/ missing?
$ web-push send-notification --endpoint=https://fcm.googleapis.com/fcm/send/<<endpoint-key>>
Error sending push message:
{ [WebPushError: Received unexpected response code]
name: 'WebPushError',
message: 'Received unexpected response code',
statusCode: 400,
headers:
{ 'content-type': 'text/html; charset=UTF-8',
date: 'Fri, 25 Nov 2016 08:54:08 GMT',
expires: 'Fri, 25 Nov 2016 08:54:08 GMT',
'cache-control': 'private, max-age=0',
'x-content-type-options': 'nosniff',
'x-frame-options': 'SAMEORIGIN',
'x-xss-protection': '1; mode=block',
server: 'GSE',
'alt-svc': 'quic=":443"; ma=2592000; v="36,35,34"',
'accept-ranges': 'none',
vary: 'Accept-Encoding',
connection: 'close' },
body: '<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' }
Any company with a website can send web push notifications after installing code (a web-based SDK from a web push service) on its website. No app is required. For users, clicking or tapping on a web push notification takes the visitor to a pre-set URL determined by the brand.
Have you used any HTTP server to test the code in that tutorial? Further, DNS should be localhost or https:// site. If you are running the HTTP server under some port, better to have 5 digit client side port. Here is linked my project browser push
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With