google-cloud-functions

Using HttpsCallable with service credentials

自古美人都是妖i 提交于 2021-02-20 02:58:09
问题 I'm using a bunch of HttpsCallable functions that are used by the client to safely invoke things on the backend. I now find myself in a situation where the backend (another cloud function) would need to trigger some of the same operations, so ideally I would just call the HttpsCallable from another cloud function. The callable library is not available in firebase-admin, and I'm assuming that's because it's doing user authentication. Would it be possible to somehow work around this? Maybe I

asyncio not working on Google Cloud Functions

半腔热情 提交于 2021-02-20 02:57:43
问题 I have this function which works fine locally on my machine with python 3.8, but it throws runtime error on Google Cloud Functions. def telegram_test(request): request_json = request.get_json() import datetime import pandas as pd from pyrogram import Client session_string = "...............38Q8uTHG5gHwyWD8nW6h................." # the rest of the authantication api_id = 32494131641215 api_hash = "ioadsfsjnjksfgnfriuthg#qw]/zwq ]w/\lc ec," # one of bbc channels on telegram you want to access

user access and data control to cloud firestore when calls to firestore are made server side

假如想象 提交于 2021-02-19 08:45:38
问题 I've started a web-based project using nodejs, express, firebase functions, firestore and eventually want to use firebase hosting. So far, I have been able to keep everything server side until I've reached Authorisation and Authentication. I'm using a model view controller structure so calls to firestore are being made server side and therefore the firestore security rules don't work. Firestore security rules only work if you access firestore client side. Can I use google cloud IAM (Identity

Providing keyFilename of Google Client Service Account from Google Cloud Storage

痞子三分冷 提交于 2021-02-19 08:15:29
问题 To connect to Google Cloud BigQuery that exists in a different GCP project from a Google Cloud Function, I am creating the BigQuery Client as follows: const {BigQuery} = require('@google-cloud/bigquery'); const options = { keyFilename: 'path/to/service_account.json', projectId: 'my_project', }; const bigquery = new BigQuery(options); But instead of storing the service_account.json in my Cloud Function, I want to store the Service Account in Google Cloud Storage and provide the Google Cloud

Firebase Cloud Functions - Delete Entries where timestamp field is over a month old and run daily

有些话、适合烂在心里 提交于 2021-02-19 05:38:10
问题 This is a two in one question. Part 1: I am storing data in Firestore, and one of my fields is an 'end_date' timestamp field. How can I write a cloud function, so that when this field is over a month in the past, the record is deleted? Part 2: How can I get this to run every day? 回答1: You can solve this problem, and related problems, relatively easy by combining the following technologies: Nodejs, firebase-admin SDK, and the async/await pattern. This is not a full solution, but just to give

Debugging Firebase functions locally (node.js)

时光怂恿深爱的人放手 提交于 2021-02-19 05:34:20
问题 see below my code is very simple....it listens to a change on a database field in realtime-database. const functions = require("firebase-functions"); var admin = require("firebase-admin"); exports.onActiveUpdate = functions.database .ref("/profiles/users/{userId}/active") .onUpdate((change, context) => { //code here return true; }); Ive tried to debug code locally with the following commands firebase serve --only functions firebase serve firebase emulators:start I always get the same message.

How to get delegated credentials objects for invoking google apis?

不想你离开。 提交于 2021-02-19 05:21:40
问题 I am trying to fetch gsuite alerts via API. I have created a service account as per their docs and I have assigned that service account to my google cloud function. I do not want to use environment variables or upload credentials along with source code but I want leverage default service account used by function. from googleapiclient.discovery import build def get_credentials(): # if one knows credentials file location(when one uploads the json credentials file or specify them in environment

“firebase serve --only functions” doesn't work

∥☆過路亽.° 提交于 2021-02-19 04:43:30
问题 $ firebase serve --only functions ⚠ Your requested "node" version "8" doesn't match your global version "12" Error: TIMEOUT: Port 5000 was not active within 30000ms but when serve hosting will success $ firebase serve --only hosting i hosting: Serving hosting files from: dist/chongsheng-jp ✔ hosting: Local server: http://localhost:5000 I thought that I didn't compile index.ts, I tried npm run serve following firebase official doc but It doesn't work. Please help me. Here is my versions.

Deployment error. Build failed: Build error details not available. Firebase Cloud Functions

丶灬走出姿态 提交于 2021-02-19 02:15:07
问题 I reinstalled multiple times NPM and Node on my pc. (npm version 7.4.3) (node version v15.7.0) I followed the procedure for configuring the Firebase CLI with: npm install -g firebase-tools and firebase init and firebase deploy and the configuration seems to work fine. The problem I'm facing happens when I open the index.js file and I uncomment the stock helloWorld function which looks like this: exports.helloWorld = functions.https.onRequest((request, response) => { functions.logger.info(

Reading Data From Cloud Storage Via Cloud Functions

本小妞迷上赌 提交于 2021-02-18 22:47:40
问题 I am trying to do a quick proof of concept for building a data processing pipeline in Python. To do this, I want to build a Google Function which will be triggered when certain .csv files will be dropped into Cloud Storage. I followed along this Google Functions Python tutorial and while the sample code does trigger the Function to create some simple logs when a file is dropped, I am really stuck on what call I have to make to actually read the contents of the data. I tried to search for an