Web推送API Chrome,返回“未经授权的注册” [英] Web Push API Chrome, returning "Unauthorized Registration"

查看:146
本文介绍了Web推送API Chrome,返回“未经授权的注册”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在 google教程,了解如何使用网络推送节点模块在Chrome上发送网络推送通知。

然而,本教程还提供了协同服务器应用程序,您应该使用它来测试从服务器向客户端发送推送通知。



但是,在配套应用程序中,甚至在本地机器上使用web-push cli时,尝试发送通知时,我都会收到未经授权的注册错误。
在网上找不到任何关于这个错误的信息 - 我做错了什么/缺少了什么?

  $ web-push send-notification --endpoint = https://fcm.googleapis.com/fcm/send/<< endpoint-key>> 
发送推送消息时出错:
{[WebPushError:收到意外响应代码]
名称:'WebPushError',
消息:'收到意外响应代码',
statusCode :400,
标题:
{'content-type':'text / html; charset = UTF-8',
日期:'Fri,2016年11月25日08:54:08 GMT',
过期:'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 body:'< HTML> \\\
< HEAD> \\\
< TITLE> UnauthorizedRegistration< / TITLE> \\\
< / HEAD> \\\
< BODY BGCOLOR =#FFFFFFTEXT =#000000 < H1>< H1> UnauthorizedRegistration< / H1> \\\
< H2>错误400< / H2> \\ n< / BODY> \\\
< / HTML> \\\
'}


解决方案

您是否使用过HTTP服务器来测试该教程中的代码?此外,DNS应该是本地主机 https:// 网站。如果您在某个端口下运行HTTP服务器,最好有5位数的客户端端口。这里链接了我的项目浏览器推送


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' }

解决方案

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

这篇关于Web推送API Chrome,返回“未经授权的注册”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆