firebase-admin

Firebase database access denied with permission set

我与影子孤独终老i 提交于 2021-01-29 13:45:14
问题 I have carefully looked at other answers to similar questions and as far as I can tell everything is set correctly but still access is denied. Minimum working example: My Firebase Live Database Security Rule for the path 'user/{uid}' is as follows "rules": { "user": { "$uid": { ".read": "auth.uid === $uid", ".write": "auth.uid === $uid && !data.exists() " } } } in the typescript I attempt to read 'user/{uid}' for some user. //Firebase and firebase-fcuntions import const firebase = require(

Jest mock not resolving to each injected value

☆樱花仙子☆ 提交于 2021-01-29 13:39:51
问题 I'm trying to test a Firebase cloud function named myCloudFn in my functions/send.js module. My tests are in functions/test/send.spec.js : // send.js const admin = require('firebase-admin'); async function myCloudFn (email) { const authUser = await admin.auth().getUserByEmail(email); return authUser; } module.exports = { myCloudFn }; // send.spec.js const send = require('../send.js'); jest.mock('firebase-admin', () => ({ auth: () => ({ getUserByEmail: jest.fn() .mockResolvedValueOnce({ uid:

Switching Firebase Auth from Android SDK to Firebase Admin SDK

匆匆过客 提交于 2021-01-29 10:01:57
问题 Currently I have an android app that uses the Firebase Auth for user Authentication. I would like to move the authentication part to the Admin Sdk server, such that The android app makes an http request to the server and the server does the authentication. Unfortunately the the Admin SDK for Java does not have the signInWithEmailAndPassword method. Is there a way to go about this or do I have to include the android sdk on the server also? 回答1: That's not a supported situation with Firebase

admin.auth().verifyIdToken(idToken) Error: Could not load the default credentials whith firebase-admin after to 8.0.0

一笑奈何 提交于 2021-01-29 06:01:35
问题 I've got a problem when i'm trying use middleware in firebase this is my middleware (FBauth) const db = admin.firestore(); const FBAuth = (_req,_res,next) => { let idToken; if(_req.headers.authorization && _req.headers.authorization.startsWith('Bearer ')){ idToken = _req.headers.authorization.split ('Bearer ')[1]; console.log('ID TOKEN ------------>', idToken); }else{ console.error('Nessun Token trovato') return _res.status(403).json({ error: 'non-autorizzato'}); } admin.auth().verifyIdToken

Firebase Admin SDK: How to use listUsers() function as Observable combining recursive calls?

岁酱吖の 提交于 2021-01-28 12:43:51
问题 How to use Firebase Admin SDK listUsers() function as an RXJS observable? I can use from RXJS function on listUsers to return an observable, but the challenge is that listUsers returns users in batches. How could these batches of users be retrieved and then merged? 回答1: The Firebase Admin SDK function listUsers could be wrapped with a function that returns an Observable . Then flatMap and forkJoin could be used to combine the recursive function calls into one array of users. import { forkJoin

Firebase Admin SDK: How to use listUsers() function as Observable combining recursive calls?

╄→гoц情女王★ 提交于 2021-01-28 12:43:21
问题 How to use Firebase Admin SDK listUsers() function as an RXJS observable? I can use from RXJS function on listUsers to return an observable, but the challenge is that listUsers returns users in batches. How could these batches of users be retrieved and then merged? 回答1: The Firebase Admin SDK function listUsers could be wrapped with a function that returns an Observable . Then flatMap and forkJoin could be used to combine the recursive function calls into one array of users. import { forkJoin

Does Firebase Admin SDK perform any caching?

人走茶凉 提交于 2021-01-28 10:08:18
问题 I've been using firebase with cloud functions recently and this question popped into my mind. If in my cloud function, using the Firebase Admin SDK, perform multiple reads to the same document in a single function call, will it count as multiple reads in the database or will it cache the data? Example: await admin.firestore().collection("users").doc("user_id_here").get(); await admin.firestore().collection("users").doc("user_id_here").get(); await admin.firestore().collection("users").doc(

Firebase Functions: Could not load default credentials

青春壹個敷衍的年華 提交于 2021-01-28 05:24:05
问题 I have a Firebase Function that subscribes to a Cloud PubSub topic. App is initialized very simply like this: import * as admin from 'firebase-admin'; admin.initializeApp(); I'm getting this error: "Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information. at GoogleAuth.getApplicationDefaultAsync (/srv/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:161:19) at process._tickCallback

Verifying password-less email signup in Firebase Admin

守給你的承諾、 提交于 2021-01-27 19:28:38
问题 I'm trying to have users of my app sign in by email + link, password-less. The client (written in React Native) asks for the sign-in link using the Javascript SDK like so, based on this answer: var actionCodeSettings = { // URL you want to redirect back to. The domain (www.example.com) for this // URL must be in the authorized domains list in the Firebase Console. url: `${BASE_URL}/verifyEmail?email=${email}`, // This must be true. handleCodeInApp: true, iOS: { bundleId: BUNDLE_ID }, android:

Python Firebase Admin SDK appears successful but I never receive the notification

我们两清 提交于 2021-01-27 16:42:42
问题 I'm attempting to use the Python Firebase Admin SDK to send push notifications for my mobile app. I've tested it with the notification composer in the Firebase Console, so I know my device can receive push notifications, but when I try to use the SDK I never receive anything. Nor do I see the notification listed on the Firebase console notification page. Here's the exact code(minus my personal info) that I'm using to send the notification: import firebase_admin from firebase_admin import