Tag: firebase admin

Firebase RangeError:检索数据时string的长度无效

我正在使用Firebase /数据库Node.js / Admin。 我试图找回超过100K的孩子(并在客户端工作)。 我得到了以下错误(加载很长时间后): /node_modules/firebase-admin/lib/database/database.js:161 function Sf(a,b){a.frames.push(b);if(a.frames.length==a.De){var c=a.frames.join("");a.frames=null;c=eb(c);a.Xf(c)}}h.send=function(a){Rf(this);a=A(a);this.ob+=a.length;Gf(this.Ua,"bytes_sent",a.length);a=pc(a,16384);1<a.length&&Tf(this,String(a.length));for(var b=0;b<a.length;b++)Tf(this,a[b])};h.Qc=function(){this.yb=!0;this.wc&&(clearInterval(this.wc),this.wc=null);this.Ha&&(this.Ha.close(),this.Ha=null)}; RangeError: Invalid string length at Array.join (native) at Sf (/node_modules/firebase-admin/lib/database/database.js:161:76) at Client.Ha.onmessage (/node_modules/firebase-admin/lib/database/database.js:159:289) 我用下面的代码与Node.js运行此: var databaseRef = defaultApp.database().ref('a_root_node'); var usersRef = databaseRef.child('users') usersRef.once('value').then(snapshot => { res.status(200).send(snapshot.val()) }) 我也尝试将其作为Firebasefunction运行,并增加了内存限制,但错误是一样的。

试图访问实时数据库时,Firebase Node.jspipe理SDK超时

使用带有Firebase函数的Node.js admin SDK每当我尝试访问实时数据库时,都会收到一个超时值。 只有在本地testing函数( firebase serve –only functions,hosting仅适用firebase serve –only functions,hosting )以及使用functions.config().firebase firebase serve –only functions,hosting初始化默认应用程序时才会发生这种情况。 这是一个刚刚发生在几天前的新行为。 但是,如果我尝试使用serviceAccount.json文件初始化默认应用程序,则一切正常。 我正在使用firebase-admin版本4.2.1和firebase firebase-functions版本0.5.9 。 我写了一个简单的http triggered函数,由于超时而失败: const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); const db = admin.database(); exports.testDbConnection = functions.https.onRequest((req, res) => { return admin.database().ref().once('value') .then(function(snapshot) { res.json(snapshot); }).catch(function(error) { res.json(error); }); });

pipe理员firebase身份validation和节点js

我正在开发android应用程序,我使用节点js后端和Firebase平台为我的应用程序,我用firebase-authpipe理用户,问题是当我注册一个新的用户使用节点js的firebase-auth我看到这个错误。 这是源代码。 function registerUser(socket,io){ ​// retrieve data from android app socket.on('userData',(data)=>{ console.log(data.email); console.log(data.userName); console.log(data.password); ​ ​// register new user using data. admin.auth().createUser({ email: data.email, password: data.password, displayName: data.userName, }) .then(function(userRecord) { // See the UserRecord reference doc for the contents of userRecord. console.log("Successfully created new user:", userRecord.uid); const db = admin.database(); const ref = db.ref('users/'); […]

强制令牌刷新,但令牌仍然过期?

var app = angular.module('app', ['firebase']); const setAppCookie = () => firebase.auth().currentUser.getToken(true).then(token => { Cookies.set('token', token, { domain: window.location.hostname, expire: 1 / 24, path: '/', secure: true }); }); const unsetAppCookie = () => Cookies.remove('token', { domain: window.location.hostname, path: '/', }); app.factory("Auth", ["$firebaseAuth", function ($firebaseAuth) { return $firebaseAuth(); }]); app.controller("ctrlHead", ["$scope", "Auth", "$window", function ($scope, Auth, […]

Firebasepipe理员SDK – DELETE响应不正确

我是新来的JavaScript(但不是新的编程)。 我正在使用NodeJs中的Firebase ADMIN SDK创build一个REST API。 如果资源存在,我能够成功执行DELETE请求。 但如果不存在(或者ID不正确),POSTMAN的响应仍然是成功的。 我想这个callback函数是不正确的。 当我实现GET /:id和PUT /:id时,我可能会看到相同的问题。 请帮忙。 // DELETE /api/billingPlans/:id // Delete a billing plan routes.delete('/:id', (req, res) => { var ref = admin.database().ref(firebaseNode); //Have also tried snapshot.exists() but similar problem occurs return ref.child(req.params.id).once('value', function(snapshot) { snapshot.ref.remove(function(error){ if(!error) res.status(200).json({"result" : "DELETE Success"}); else res.status(204).json({"error" : "Not found"}); }); });

pipe理FCM设备组服务器端

我正在寻找一种方法来pipe理FCM设备组服务器端,希望通过使用node.js firebase-admin库。 就我所见,实现这一目标的唯一方法是使用基于GCM的旧restterminalPOST: https://android.googleapis.com/gcm/notification 但是,我不觉得使用这个gcm系统是不自信的。 我已经通过github回购search,cound似乎没有find任何Device Groups任何地方。 这个function是不是应该被使用了吗? 或者是由于某种原因可能没有logging,或者被忽略了? 我知道,创build设备组是可以在客户端实现的,但似乎要求用户有一个谷歌帐户,这不幸的是在我的情况下,我不能假设。 从https://firebase.google.com/docs/cloud-messaging/android/device-group#managing_device_groups 要在客户端上创build设备组,该设备必须至less有一个Google帐户。

通过电子邮件创build的Firebase-Admin用户显示为匿名

我用一个最小的(名字/电子邮件/密码)表单使用admin sdk。 用提供的电子邮件创build的用户仍然在控制台中匿名显示。 我的代码:(NodeJs) const admin = require('firebase-admin'); const secret = require('./../credentials/server'); admin.initializeApp({ credential: admin.credential.cert(secret), databaseURL: 'url', }); module.exports = (user) => { admin.auth().createUser({ email: user.email, password: user.password, displayName: user.name, }) .then((userRecord) => { // See the UserRecord reference doc for the contents of userRecord. console.log('Successfully created new user:', userRecord.uid); }) .catch((error) => { console.log('Error […]

Admin SDK Auth错误,错误的错误代码

我正在使用Admin SDK,Authfunction。 当调用admin.auth().verifyIdToken(token)并且令牌已经过期时,我得到错误 Firebase ID令牌已过期。 从您的客户端应用程序获取新的令牌,然后重试。 有关如何检索ID令牌的详细信息,请参阅https://firebase.google.com/docs/auth/admin/verify-id-tokens 。 有错误代码 AUTH /参数误差 首先,错误代码是不是“auth / user-token-expired”? 其次,我收到的错误代码不在pipe理员身份validationAPI错误中 我很难妥善处理所有的firebase错误,所以我可以回复适当的错误消息给我的API的消费者。

从TypeScript Firebase Admin SDK初始化失败

我正在尝试在我的TypeScript(Nest.js)应用程序中导入Firebase Admin SDK。 let serviceAccount = require("../../creds.json"); console.log(serviceAccount); const firebase = require("firebase"); firebase.initializeApp(environment.firebase); admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: "projectid" }); 但是当我尝试构build应用程序时,出现以下错误。 ERROR in ./node_modules/@google-cloud/firestore/src/v1beta1/firestore_client.js Module not found: Error: Can't resolve './firestore_client_config' in '/home/jaybell/trellis-server/trellis/node_modules/@google-cloud/firestore/src/v1beta1' @ ./node_modules/@google-cloud/firestore/src/v1beta1/firestore_client.js 28:17-53 @ ./node_modules/@google-cloud/firestore/src/v1beta1/index.js @ ./node_modules/@google-cloud/firestore/src/index.js @ ./src/server/main.server.ts ERROR in ./node_modules/google-gax/lib/operations_client.js Module not found: Error: Can't resolve './operations_client_config' in '/home/jaybell/trellis-server/trellis/node_modules/google-gax/lib' @ ./node_modules/google-gax/lib/operations_client.js […]

如何在不知道Firebase和Firebase-admin中的密钥的情况下让孩子一触即发

我的数据库中有一个队列,如下所示: server queue -RANDOM_ID_1234 active: "true" text: "Some text" -RANDOM_ID_5678 active: "false" text: "Another text" -RANDOM_ID_91011 active: "false" text: "Text that does not matter" 我想查询并获取活动项目: queueRef.orderByChild('active').equalTo('true').once('value', function(snap) { if (snap.exists()) { console.log(snap.val()); } }); console.log将返回类似于: { -RANDOM_ID_1234: { active: "true" text: "Some text" } } 如何在不知道密钥的情况下获取文本? 我使用lodash(请参阅下面的答案),但是必须有更好的方法来做到这一点。