简体   繁体   English

我无法实现在 firebase 控制台中创建主题的云函数

[英]I can not implement a Cloud Function that creates a topic in the firebase console

I am trying to implement a firebase function, which executes the creation of a topic in the firebase console.我正在尝试实现一个 firebase 函数,该函数在 firebase 控制台中执行主题的创建。

Here is mi code:这是我的代码:

exports.createGroupTopic = functions.database.ref("/FDSF/equipos/{equipoID}/").onWrite(event => {
let eventSnapshot = event.data;
let nombreEquipo = eventSnapshot.child('nombre').val();
console.log(nombreEquipo);
request({
  method: 'POST',
  url: 'https://iid.googleapis.com/iid/v1/IID_TOKEN/rel/topics/'+ nombreEquipo,
  headers: {
    'Content-Type':'application/json',
    'Content-Length': 0,
    'Authorization':'API_KEY'
  }
}, ...

After performing the deploy, observing the output of the console, I get the following error:执行部署后,观察控制台的输出,我收到以下错误:Firebase 控制台输出

The value of the Authorization header is the server key prefixed by key= , as shown in this example in the documentation : Authorization 标头的值是以key=为前缀的服务器密钥,如文档中的此示例所示:

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

Prefix your server key with key= .使用key=您的服务器密钥添加前缀。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase云功能,用于使用主题发送推送通知 - Firebase cloud function for sending push notification using topic 如何为 firebase 实现异步调度云 function? - How to implement async scheduled cloud function for firebase? 为什么我的 Firebase Cloud Function 不能使用“allAuthenticatedUsers”? - Why can't I use `allAuthenticatedUsers` for my Firebase Cloud Function? Firebase Cloud Function - 我该如何解决这个错误:ECONNRESET - Firebase Cloud Function - How can I solve this error: ECONNRESET 如何在Firebase中的应用程序中使用云功能 - How can i use cloud function with app in Firebase 如何从 firebase 云 function 发送自定义响应? - How can I send a custom response from a firebase cloud function? 我怎样才能正确地消除 firebase 云 function 的执行 - How can i debounce the execution of a firebase cloud function correctly Firebase云功能仅在我从控制台手动将数据添加到Firestore时触发 - Firebase cloud function only triggering when I manually add data to firestore from console firebase 云计划 function 不在控制台上打印任何内容 - firebase cloud schedule function not printing anything out on console firebase 推送通知功能主题名称 - firebase pushnotification function topic name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM