使用 firebase init --debug 时的错误
[2019-01-28T05:32:18.956Z] Error Context: {
"body": {
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
},
"response": {
"statusCode": 403,
"body": {
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
},
"headers": {
"vary": "X-Origin, Referer, Origin,Accept-Encoding",
"content-type": "application/json; charset=UTF-8",
"date": "Mon, 28 Jan 2019 05:32:18 GMT",
"server": "ESF",
"cache-control": "private",
"x-xss-protection": "1; mode=block",
"x-frame-options": "SAMEORIGIN",
"x-content-type-options": "nosniff",
"alt-svc": "quic=\":443\"; ma=2592000; v=\"44,43,39\"",
"accept-ranges": "none", …Run Code Online (Sandbox Code Playgroud) 如何在 firebase 云函数 shell 中添加身份验证令牌,以测试需要身份验证的可调用对象?
用户身份验证令牌的良好语法是什么:
firebase > myAwsomeCallable({foo:"bar"},{"whatIsKeyforToken:"token");
Run Code Online (Sandbox Code Playgroud)
有谁知道一个有效的例子?第二个参数的正确数据结构是什么(可调用签名中的上下文/身份验证)?
此致
firebase firebase-authentication google-cloud-functions firebase-cli
我正在练习使用 Firebase 云功能制作 TelegramBot。安装了 firebase-tools,注册了 firebase 帐户并创建了一个新的示例项目,但是当我选择该项目时出现错误。
这是错误消息:
函数不是有效的特征。必须是数据库、firestore、函数、托管、存储之一。
我有一个 firebase 云函数,它从云 Firestore 获取数据。
const userSnapshot = await admin.firestore().collection('users').doc(user).get()
Run Code Online (Sandbox Code Playgroud)
当使用firebase emulators:start.
我收到以下错误:
The Cloud Firestore emulator is not running so database operations will fail with a 'default credentials' error.
? Google API requested!
- URL: "https://oauth2.googleapis.com/token"
- Be careful, this may be a production service.
> Auth error:Error: invalid_grant
Run Code Online (Sandbox Code Playgroud)
只有在更新 firebase-tools 后才会发生这种情况。以前使用firebase serve --only function --port=9000. 在此工具版本中,我无法通过命令行设置端口。
我已经设置了以下容器 Dockerfile:
FROM devillex/docker-firebase
ENV USER=app
RUN apt-get update && apt-get install -y openssl \
libssl-dev \
bash \
less \
vim \
gnupg \
curl \
net-tools \
apt-transport-https \
ca-certificates; \
CLOUD_SDK_REPO="cloud-sdk-$(grep VERSION_CODENAME /etc/os-release | cut -d '=' -f 2)" &&\
echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list &&\
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -; \
apt-get update && apt-get install -y \
google-cloud-sdk \
google-cloud-sdk-cloud-build-local &&\
gcloud config set project request-a-dance
RUN adduser --disabled-password --gecos …Run Code Online (Sandbox Code Playgroud) 我正在使用Github Workflows运行 nodejs 构建,我希望能够构建我的项目,然后立即将其部署到我的 firebase 项目。使用 Firebase 部署。但是如果我想使用 firebase-tools,我必须登录构建服务器。但是没有办法通过电子邮件和密码等进行身份验证。有没有办法让我完成我想要完成的任务?firebase-tools在我的构建脚本中是“react-scripts build && firebase deploy”
这是我的工作流文件 nodejs.yml:
name: Node CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm i -g firebase-tools
firebase login
npm ci
npm run build --if-present
npm test
env:
CI: true
Run Code Online (Sandbox Code Playgroud) 我已将函数部署到 gcloud 函数,我想配置 CI/CD 以从 gitlab 部署此函数。要从 gitlab 执行任何操作,我需要使用 firebase auth 令牌
firebase login:ci
命令。
问题是当我运行时,我需要使用 gcloud 服务帐户获取此令牌,该令牌未显示在浏览器中
firebase login:ci
我有这样的服务帐户数据(project_id,private_key,private_key_id等)
我应该如何授权使用这个acc?
使用以下代码:
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp()
exports.onTest = functions.https.onRequest(async (req, res) => {
res.json({ msg: 'done' })
})
Run Code Online (Sandbox Code Playgroud)
这完全来自示例文档,...firebase emulators:start从 cli运行会生成以下错误:
? TypeError: instance.registerVersion is not a function
at registerDatabase (/Users/<path>/functions/node_modules/@firebase/database/dist/index.node.cjs.js:15188:14)
at Object.<anonymous> (/Users/<path>/functions/node_modules/@firebase/database/dist/index.node.cjs.js:15200:5)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at FirebaseNamespace.get [as database] (/Users/tremendus/Development/kulanu/playground/kulanu-cloud/functions/node_modules/firebase-admin/lib/firebase-namespace.js:282:38)
? We were unable to load your functions code. (see above)
Run Code Online (Sandbox Code Playgroud)
在SO和其他网站其他几个例子调用 …
我一直在尝试实现一些从 Cloud Firestore 读取数据的 Cloud Functions。我想在本地测试这些,但是我无法运行 Cloud Firestore 模拟器。我的假设是问题出在哪里,但可能在其他地方 - 如果是这种情况,请告诉我。
这是我的功能:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin'
admin.initializeApp()
//Functions to fetch the documents in the user collection and send them to the client.
export const getUserDocs = functions.https.onRequest((request, response) => {
admin.firestore().doc('/Users/{documentId}').get()
.then(snapshot => {
const data = snapshot.data()
response.send(data)
})
.catch(error => {
response.status(500).send(error)
})
})
Run Code Online (Sandbox Code Playgroud)
这是我运行命令时得到的错误firebase serve --only functions:
Carlo@Carlos-Air-2 functions % firebase serve --only functions
? Your requested …Run Code Online (Sandbox Code Playgroud) firebase google-cloud-functions google-cloud-firestore firebase-cli
会有人知道,如果有一种方法来初始化一个火力地堡功能(使用仿真器来调试本地)与HTTP小号地址,而不是默认的HTTP?我正在尝试调试与 Telegram bot 相关的脚本,而 Telegram 只允许 http的webhook。
外壳输出如下:
PS C:\Users\<user>\Desktop\tmp_node\functions> firebase emulators:start --only functions
i emulators: Starting emulators: functions
+ hub: emulator hub started at http://localhost:4400
+ functions: Using node@10 from host.
+ functions: functions emulator started at http://localhost:8443
i functions: Watching "C:\Users\<user>\Desktop\tmp_node\functions" for Cloud Functions...
+ functions[<function name>]: http function initialized (http://localhost:8443/<endpoint>).
+ emulators: All emulators started, it is now safe to connect.
Run Code Online (Sandbox Code Playgroud)
我需要它从 http s ://localhost:8443/ 开始。
非常感谢您提前!
firebase telegram-bot google-cloud-functions telegram-webhook firebase-cli
firebase ×10
firebase-cli ×10
node.js ×2
docker ×1
gcloud ×1
github ×1
local ×1
telegram-bot ×1