google-cloud-functions

How to impersonate the database authentication from Firebase Cloud Function with admin privileges?

六月ゝ 毕业季﹏ 提交于 2020-08-08 04:30:06
问题 I have a set of Firebase Functions that works as an API for an application. These Firebase Functions connect to the database with admin privileges as this: const serviceAccount = require(`./config/xxx-firebase-adminsdk.json`); admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: DATABASE_URL, }); I was able to create a custom token and I'm receiving/decoding it in the server but I cannot make use of the security rules because the Firebase function is

Firebase-functions-test “The default Firebase app does not exist.”

我的未来我决定 提交于 2020-08-07 03:25:17
问题 I've begun using the new firebase-functions-test testing SDK to unit test my Cloud Firestore functions. When I run my tests via npm test I am getting the following error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services My method is very similar to the makeUppercase method found within the quickstarts samples, and thus I have mainly copied the test from the test.js file. describe('updateActiveNotesCount', () => { // Test

Firebase-functions-test “The default Firebase app does not exist.”

只愿长相守 提交于 2020-08-07 03:24:19
问题 I've begun using the new firebase-functions-test testing SDK to unit test my Cloud Firestore functions. When I run my tests via npm test I am getting the following error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services My method is very similar to the makeUppercase method found within the quickstarts samples, and thus I have mainly copied the test from the test.js file. describe('updateActiveNotesCount', () => { // Test

Nodejs Firebase Transaction - Maximum call stack size exceeded

為{幸葍}努か 提交于 2020-08-06 05:23:17
问题 I have a cloud function that uses a transaction to updates the players in a game. When the /players is null, i am trying to return a Map, but i get "Maximum call stack size exceeded". Here is my cloud function: export const addUserToGame = functions.https.onCall((data, context) => { // Expected inputs - game_id(from data) and UID(from context) if (context.auth == null) { return { "status": 403, "message": "You are not authorized to access this feature" }; } const uid = context.auth.uid; const

How to use the sendPasswordResetEmail() function on the server using the firebase-admin SDK?

你说的曾经没有我的故事 提交于 2020-08-05 19:26:31
问题 In the past, I have used firebase.auth in the web client and once a user creates another user, I link certain security logic: Once the user has been created I send an email to verify your email with the function user.sendEmailVerification (). As the user was created by another user, I assign a default password and use the sendPasswordResetEmail () function so that the user registers his new password. That has worked well for me so far, but now for many reasons I need to move that logic to my

How to use the sendPasswordResetEmail() function on the server using the firebase-admin SDK?

青春壹個敷衍的年華 提交于 2020-08-05 19:26:08
问题 In the past, I have used firebase.auth in the web client and once a user creates another user, I link certain security logic: Once the user has been created I send an email to verify your email with the function user.sendEmailVerification (). As the user was created by another user, I assign a default password and use the sendPasswordResetEmail () function so that the user registers his new password. That has worked well for me so far, but now for many reasons I need to move that logic to my

How to get data from wildcard in firebase cloud functions

你离开我真会死。 提交于 2020-07-29 06:08:34
问题 Assuming that I trigger events on the following ref('/users/{userId}/items/{newItem}') I want to get a value from inside the wildcard userId I have tried var token = event.params.userId.token but it return to be undefined Any suggestions? 回答1: Token is not a parameter returned automatically from trigger events. In trigger wild cards only parameters corresponding directly to the wildcard are returned. So You need to do the following if you want to use the var userId = event.params.userId And

How to get data from wildcard in firebase cloud functions

安稳与你 提交于 2020-07-29 06:08:01
问题 Assuming that I trigger events on the following ref('/users/{userId}/items/{newItem}') I want to get a value from inside the wildcard userId I have tried var token = event.params.userId.token but it return to be undefined Any suggestions? 回答1: Token is not a parameter returned automatically from trigger events. In trigger wild cards only parameters corresponding directly to the wildcard are returned. So You need to do the following if you want to use the var userId = event.params.userId And

Google cloud functions http authentication

时间秒杀一切 提交于 2020-07-28 04:22:27
问题 I am new to google cloud functions and try to restrict access to my function by only requests from dialogflow webhooks. I see two options in gcloud console: allow unauthenticated requests and restrict by user accounts. I don't understand how to implement that authentication. Dialogflow webhooks has options to set http headers that sets in webhook requests. But gcloud console hasn't interface/options to obtain any data that I can write as http authentication header. So I see only option

Google cloud functions http authentication

筅森魡賤 提交于 2020-07-28 04:22:17
问题 I am new to google cloud functions and try to restrict access to my function by only requests from dialogflow webhooks. I see two options in gcloud console: allow unauthenticated requests and restrict by user accounts. I don't understand how to implement that authentication. Dialogflow webhooks has options to set http headers that sets in webhook requests. But gcloud console hasn't interface/options to obtain any data that I can write as http authentication header. So I see only option