标签: firebase-admin

如何使用firebase admin sdk列出所有用户

有没有办法列出使用firebase admin sdk的所有用户?文档仅显示通过uid或电子邮件获取一个用户.

firebase firebase-authentication firebase-admin

7
推荐指数
3
解决办法
7458
查看次数

Firebase-使用Firebase管理员SDK在子域之间共享身份验证

我已经完成了一些有关共享auth object应用程序子域的研究。显然,firebase的网络SDK就是这种设置。

我的想法是拥有一个login.myapp.com可供我的其他应用程序使用的登录网站app1.myapp.comapp2.myapp.com以进行身份​​验证。就像谷歌一样。

我的第一个尝试是从中stringify()访问auth对象localStorage,然后将其作为url参数发送到发出请求的应用程序,以便我可以parse()将auth对象并将其存储到该应用程序的localStorage

但是我不喜欢这种设置,不仅令牌会记录在浏览器的历史记录中,而且看起来也很奇怪。

所以我想知道是否有使用admin sdk的已知设置。

  1. 从获取身份验证 login.myapp.com
  2. 传递uidapp1.myapp.com
  3. app1.myapp.comuid通过http 传递到服务器
  4. 服务器将检查是否uid已通过身份验证。
  5. 如果成功,服务器将响应一个auth objectapp1.myapp.com

Firebase管理员可以产生这样的信息吗?

在此处输入图片说明

firebase firebase-authentication firebase-admin

7
推荐指数
1
解决办法
1438
查看次数

是否可以通过Firebase Admin SDK从我的Node.js服务器发送验证电子邮件?

有没有办法从我的服务器发送电子邮件验证电子邮件?

这是在客户端上完成的方式:

authData.sendEmailVerification().then(function() {
Run Code Online (Sandbox Code Playgroud)

有没有办法在服务器上做到这一点?

node.js firebase firebase-authentication firebase-admin

7
推荐指数
2
解决办法
2398
查看次数

我可以使用Firebase Admin SDK for Node重置用户密码吗?

Firebase提供的文档表明API提供与控制台相同的功能:

要访问Firebase控制台以管理Firebase用户并不总是很方便.管理员用户管理API提供对这些相同用户的编程访问.它甚至允许您执行Firebase控制台无法执行的操作,例如检索用户的完整数据以及更改用户的密码,电子邮件地址或电话号码.

但是参考文档没有列出重置用户密码的功能.我错过了什么吗?

node.js firebase firebase-admin

7
推荐指数
2
解决办法
3409
查看次数

Cloud Storage for Firebase访问错误“ admin.storage(...)。ref不是函数”

我正在使用Cloud Storage for Firebase,无法弄清楚如何访问存储文件

根据https://firebase.google.com/docs/storage/web/start官方指南和https://firebase.google.com/docs/storage/web/create-reference,此代码应返回根引用

let admin = require('firebase-admin')
admin.initializeApp({...})
let storageRef = admin.storage().ref()
Run Code Online (Sandbox Code Playgroud)

但这引发了错误

TypeError:admin.storage(...)。ref不是一个函数

package.json

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {...},
  "dependencies": {
    "@google-cloud/storage": "^1.5.1",
    "firebase": "^4.8.0",
    "firebase-admin": "~5.4.2",
    "firebase-functions": "^0.7.1",
    "pdfkit": "^0.8.3",
    "uuid": "^3.1.0"
  },
  "private": true
}
Run Code Online (Sandbox Code Playgroud)

节点-v => v7.7.4

我的最终目标是下载文件或将pdf文件上传到存储。

node.js firebase firebase-storage firebase-admin

7
推荐指数
1
解决办法
5092
查看次数

ImportError:无法为Python导入Cloud Firestore库

尝试在python服务器上集成Google Firestore API

...
  File "/home/daffolap-355/repos/subscriptions/appvendor/firebase_admin/firestore.py", line 28, in <module>
    raise ImportError('Failed to import the Cloud Firestore library for Python. Make sure '
ImportError: Failed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.
Run Code Online (Sandbox Code Playgroud)

我在这里收到此错误:

from firebase_admin import credentials, auth, firestore

我安装了firebase-admin模块:

pip install --upgrade -t libs firebase-admin

并运行应用

dev_appserver app.yaml

python google-app-engine firebase firebase-admin google-cloud-firestore

7
推荐指数
2
解决办法
3287
查看次数

Firebase-admin无法预测的阅读时间

我有一个Firebase数据库,客户端通过在node.js上运行的REST API访问,然后使用firebase-admin节点客户端从我的firebase数据库中读取.对于我的大多数端点,需要几个并发数据库读取.例如,对于api/item/:itemKey终点,我需要拉item从数据库中,然后,一旦已收到,我同时向所有的嵌套的spec,panel,querytask与检索到的项目相关联的对象.这使得数据库调用连续两次"波动":第一项检索,然后检索嵌套在该项中的所有资源.

问题是这些调用的延迟非常难以预测.例如,以下是对同一端点的两次连续调用的日志,彼此在5秒内完成:

// START REQUEST 1
Endpoint activated (invocation #: 18) ("GET /api/items/:itemKey")
Firebase items READ Success ("id: -LDhjV8Hkievzbh5UVfz"): 78ms
Firebase specs READ Success ("id: -LDIezNhwWX8OmoWXZO3"): 72ms
Firebase specs READ Success ("id: -LDIezNqbVuvkpr9WEf8"): 73ms
Firebase panels READ Success ("id: -LDhjV5y1mAwPmJkE4d3"): 74ms
Firebase queries READ Success ("id: -LDhjV34aJlz_XFwOp6B"): 69ms
Firebase queries READ Success ("id: -LDhjV3QO1AM9UiCVdux"): 71ms
Firebase tasks READ Success ("id: -LDhjV34aJlz_XFwOp6C"): 71ms
Firebase tasks READ …
Run Code Online (Sandbox Code Playgroud)

database-performance node.js firebase firebase-realtime-database firebase-admin

7
推荐指数
0
解决办法
119
查看次数

Firebase 存储:列出特定目录中的文件

如何在特定目录(例如:/test)中列出 Firebase 存储中的文件,

这是我尝试过的:

 var query = {
    delimiter: 'test/'
};

const storageRef = admin.storage().bucket().getFiles(query, function(err, files, nextQuery, apiResponse) {

  console.log(files);
}
Run Code Online (Sandbox Code Playgroud)

但它返回存储桶根目录下的文件..

任何的想法?

node.js google-cloud-storage firebase firebase-storage firebase-admin

6
推荐指数
1
解决办法
3548
查看次数

使用 firebase_admin 或 google.cloud.firestore 在 python 中的 Firestore 客户端(作为用户)

我正在构建一个使用 Firestore 的 python 客户端应用程序。我已成功使用 Google Identity Platform 注册并登录 Firebase 项目,并使用 google.cloud.firestore.Client 创建了一个工作 Firestore 客户端,该客户端已通过用户身份验证:

import json
import requests
import google.oauth2.credentials
from google.cloud import firestore

request_url = f"https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key={self.__api_key}"
headers = {"Content-Type": "application/json; charset=UTF-8"}
data = json.dumps({"email": self.__email, "password": self.__password, "returnSecureToken": True})
response = requests.post(request_url, headers=headers, data=data)
try:
    response.raise_for_status()
except (HTTPError, Exception):
    content = response.json()
    error = f"error: {content['error']['message']}"
    raise AuthError(error)

json_response = response.json()
self.__token = json_response["idToken"]
self.__refresh_token = json_response["refreshToken"]

credentials = google.oauth2.credentials.Credentials(self.__token,
                                                    self.__refresh_token,
                                                    client_id="",
                                                    client_secret="",
                                                    token_uri=f"https://securetoken.googleapis.com/v1/token?key={self.__api_key}"
                                                    )

self.__db = firestore.Client(self.__project_id, …
Run Code Online (Sandbox Code Playgroud)

python google-authentication firebase-authentication firebase-admin google-cloud-firestore

6
推荐指数
1
解决办法
435
查看次数

Firebase Cloud Functions 上“尝试向 FCM 服务器进行身份验证时发生错误”

我正在尝试通过创建 Firestore 文档(消息)时触发的 Firebase 云函数中的 FCM 向主题发送消息。订阅主题(也使用函数完成)并触发发送函数工作正常,但实际发送失败,并显示:

Error: An error occurred when trying to authenticate to the FCM servers. Make sure the credential used to authenticate this SDK has the proper permissions. See https://firebase.google.com/docs/admin/setup for setup instructions.
Run Code Online (Sandbox Code Playgroud)

以及一些包含<H1>PROJECT_NOT_PERMITTED</H1>和的原始 HTML <H1>PROJECT_NOT_PERMITTED</H1>

这是我的代码(index.ts):

Error: An error occurred when trying to authenticate to the FCM servers. Make sure the credential used to authenticate this SDK has the proper permissions. See https://firebase.google.com/docs/admin/setup for setup instructions.
Run Code Online (Sandbox Code Playgroud)

和(messages.ts):

import * as admin from …
Run Code Online (Sandbox Code Playgroud)

firebase typescript google-cloud-functions firebase-cloud-messaging firebase-admin

6
推荐指数
1
解决办法
2953
查看次数