Firebase 401 未经授权的错误 FCM

Firebase 401 unauthorized error FCM(Firebase 401 未经授权的错误 FCM)
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)