Firebase 401 未经授权的错误 FCM [英] Firebase 401 unauthorized error FCM

查看:37
本文介绍了Firebase 401 未经授权的错误 FCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试测试 Firebase Cloud 消息传递 API,因为控制台无法提供所有功能(尤其是在应用处于后台时自定义通知).但由于某些原因,我无法让它工作,并且总是显示 401 错误.我调查了这个原因,并在重新生成新的服务器密钥后尝试了它,但错误仍然存​​在.令人惊讶的是,当我生成一个新的服务器密钥时,它并没有反映在 Firebase 控制台中,它显示服务器密钥为空.另外,我尝试将我的 IP 地址添加到服务器白名单 IP,但仍然没有运气.我附上了我对 Postman 所做的请求的屏幕截图(我用服务器密钥代替 serverKey.

I'm trying to test out Firebase Cloud messaging APIs as all functionality is not available from console (notably customization of notifications when app is in background). But for some reasons, I cannot get it to work, and it always shows up 401 error. I investigated the reasons for this, and tried it after regenerating new server key, but the error remains constant. Surprisingly, when I generated a new server key, it is not reflected in Firebase console and it shows server key as empty. Also, I tried adding my IP address to the server whitelist IPs but still no luck. I've attached a screenshot of a request that I did with Postman (I substitue the server key in place of serverKey.

我在这个问题上坚持了几个小时,非常感谢一些帮助.

I'm stuck on this for a few hours and would really appreciate some help.

推荐答案

我从您的屏幕截图中注意到您使用的是key: serverKey".您可以尝试改用key=serverKey"吗?

I noticed from your screenshot that you were using "key: serverKey". Could you try using "key=serverKey" instead?

您也不需要POST fcm.googleapus.com/fcm/send";这不是正确的 json,可以解释您看到的错误.请求的 URL 已在其他地方定义,因此请将其从有效负载中删除.

Also you don't need to have "POST fcm.googleapus.com/fcm/send"; this is not proper json and would explain the error you are seeing. The URL of the request is already defined elsewhere so remove it from the payload.

这篇关于Firebase 401 未经授权的错误 FCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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