Tag: firebase

无法使用GitHub个人访问令牌validationFirebase(以前工作)

此代码用于工作,但现在我得到错误时尝试进行身份validation。 这是一个简单的例子,所以你可以重新创build这个问题。 这是一个使用最新版本的firebase模块(3.4.1)的Node脚本。 我刚刚生成了一个启用了所有权限的新的GitHub个人访问令牌。 我仍然得到相同的错误。 var firebase = require('firebase'); var config = { apiKey: "REDACTED", authDomain: "REDACTED", databaseURL: "REDACTED", storageBucket: "REDACTED", messagingSenderId: "REDACTED" }; firebase.initializeApp(config); var credential = firebase.auth.GithubAuthProvider.credential('REDACTED'); firebase.auth().signInWithCredential(credential) 这是错误: { "error":{ "errors":[ { "domain":"global", "reason":"invalid", "message":"Unsuccessful check authorization response from Github: {\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}" } ], "code":400, "message":"Unsuccessful check authorization response from Github: {\"message\":\"Bad […]

如何只获取Firebase数据库的更改值?

如何只获取Firebase数据库的更改值? 因为每次我改变了一个值,如: / some_user ~ id ~ name / data ~ order_id ~ order_name <<= Changed in here 但是,当我得到改变的数据,我得到所有的树结构,不仅改变了数据order_name 。 所以我只是想要它返回这样的东西: / some_user / data ~ order_name <<= Specific changed data 所以我可以确定哪些是确切的key数据已经改变。 我怎样才能做到这一点? 谢谢。

Firebase-admin不会写入数据库,不会出现错误

Firebasepipe理员不写入数据库。 我正在实例化数据库: var db = admin.database(); 然后设置一个我想要的表的引用: var systemsRef = db.ref("systems/"); 然后我有一个函数来检查'系统'(一个encryption的硬件ID)是否存在。 function isSystemRegistered(id){ var isTrue; systemsRef.once('value', function(snapshot) { isTrue = (snapshot.hasChild(id))? true : false; }); return isTrue; } 其中,至今仍然是false ; 这是true ,因为它还不存在。 如果系统不存在,则写入数据。 const sysID = getSysID(); var sys.info.name = generateUniqueSystemName(); if(isSystemRegistered(sysID){ console.log("system is already registered!"); } else { msystemsRef.set({ sysID : sys.info.name }, […]

对所有http请求使用Firebase函数ENOTFOUND

我试图设置一个函数,使用Express和发出HTTP请求,但我总是得到一个ENOTFOUND错误,无论我的要求。 我已经尝试使用4个不同的库(https,request,request-promise,requestify)提出请求,但是都给出了相同的错误。 我遵循这个例子来设置系统: minimal-webhook + authorized-https-endpoint 。 我的基本testingfunction,那也抛出了错误: "use strict"; const functions = require("firebase-functions"); const admin = require("firebase-admin"); admin.initializeApp(functions.config().firebase); const express = require("express"); const app = express(); const https = require("https"); app.get("*", (req, res) => { var testReq = https.request({ host: "www.google.com", path: "/recaptcha/api/siteverify" }, (res) => { console.log("Finished with response " + res); }); […]

使用来自Firebase实时触发器function的其他参考值

您好我开始添加一些后端逻辑到我的Android应用程序使用的Firebase函数我想使用一些不同的事件数据值的值 exports.makeUppercase = functions.database.ref('path') .onWrite(event => { const original = event.data.val(); //I want to use value like this. const other_val= root.database.ref('path').val(); console.log('email', "firms", original); const uppercase = original.toUpperCase(); return event.data.ref.parent.child('uppercase').set(uppercase); }); 我想使用other_valwith事件数据,但到目前为止,我只是使用事件数据参考,但我可以上升或下降数据库event.data.ref使用更多的父母或孩子。 我该如何解决? 编辑:我试图学习正确的方式来做到这一点感谢@davidtaubmann的答案。 exports.makeUppercase = functions.database.ref('/nonVerifiedUsers/{email}') .onWrite(event => { var changed= ""; // You can use ref parameter like this var param=event.params.email; admin.database().ref('/uppercase').once('value').then(function(snap){ changed=snap.val(); […]

如何检查https云function的身份validation?

我想弄清楚是否可以从客户端检查auth对象,调用firebase https云function来完成以下任务: 1)只允许validation过的电子邮件用户呼叫https端点,否则返回403。 2)以某种方式访问​​调用函数的客户端的uid,以便在数据库中设置节点像characters/:uid 。 原因是不允许重复的字符。 我可以在req.body中手动传递uid ,但这意味着任何人都可以摆弄这个,并通过发送任何types的uid作为req.body载荷来创build100个不同的字符。 只有解决方法我可以想到这是改变这种逻辑到数据库触发器,即客户端写入数据库void/characters/uid节点(数据库规则做这个整个validation),然后函数监听数据库中的这种变化,处理数据,并推动它characters/uid 但这意味着需要额外的逻辑,例如删除节点后,我不知道如何发回错误或成功的响应回到客户端,就像使用https函数,我们可以res.send(200)或发回错误。

无法获取节点JS应用程序中的Firebase运行

我正在尝试使用NodeJS设置firebase JS客户端。 到目前为止,这是我的代码 var firebase = require('firebase/app'); require('firebase/database'); var config = { apiKey: "MY_SECRET_KEY_fhcWICPI", authDomain: "my_fir_app.firebaseapp.com", databaseURL: "https://my_fir_app.firebaseio.com", }; var firApp = firebase.initializeApp(config); firebase.database.enableLogging(true) // Get a reference to the database service var database = firebase.database(); 那么这里是我的Firebasefunction之一,用于将数据保存到实时数据库。 /** * This will save the authors of stories in Firebase * @param {String} id The ID of […]

为什么Firebase的云端function需要25秒?

为了清楚起见,我有其他的云function,它们都是间歇性地运行的(例如,从大约2-6秒的“冷”开始,并且全部使用相同的样板设置来导入pipe理实例并将该function作为模块输出) 我见过其他类似的post,但这实在是在烦扰我。 我有这样的云function: const admin = require('../AdminConfig'); const { reportError } = require('../ReportError'); module.exports = (event) => { const uid = event.params.uid; const snapshot = event.data; if (snapshot._newData === null ) { return null; } console.log('Create org begin running: ', Date.now()); const organisation = event.data.val(); const rootRef = admin.database().ref(); const ref = rootRef.child('/organisations').push(); const oid […]

Firebase和第三方API的云端函数

我的问题是使用一个API以及Firebase函数,所讨论的API是Coinbase,我使用带有节点的API,如果我使用节点命令在terminal中testing它的工作方式,但是当我将它与Firebase函数一起使用时根本不工作,我一直在试图解决这个问题近一个星期了。 代码如下> var functions = require('firebase-functions'); var Client = require('coinbase').Client; var client = new Client({ "apiKey": "xxxxxxxxxxxx", "apiSecret": "xxxxxxxxxxxxxxxxxxxxxxx" }); exports.helloWorld = functions.https.onRequest((request, response) => { this.client.getAccounts({}, function(err, accounts) { if(accounts){ response.send(accounts); }else{ response.send(err); } }); }); 错误: https : //us-central1-investimentos-b7406.cloudfunctions.net/helloWorld Coinbase API: https : //developers.coinbase.com/docs/wallet/guides/bitcoin-wallet

Cloud Functions和Nodejs中的firebase.database.refpath语法

// cloud functions exports.listenOnWrite = functions.database.ref('/foo/{id}').onWrite(event => { console.log("did match…."); }) 匹配例如:/ foo / 123123和/ foo / jk3489 // node.js function startLitener() { firebase.database().ref("/foo/{id}").on('child_added', function (postSnapshot) { console.log("did match…."); }); }; 不匹配任何东西 1)问题 我理解refpath中非常舒适的{}语法仅适用于云function。 还是我错过了什么? 2)问题 我如何在nodejs服务器上编写ref('/foo/{id}') ?