防火墙配置
我的Firebase Project 中有这两个服务帐户
1) project-id@appspot.gserviceaccount.com
2) firebase-adminsdk-8myok@project-id.iam.gserviceaccount.com
在IAM配置中,第一个帐户具有角色";编辑器";,第二个有:
1) Administrator Service Agent for the Administrator SDK
2) Service account token creator
3) Storage Manager
我的云功能代码只是:
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const sizeOf = require("image-size");
const url = require("url");
const https = require("https");
// Initialize App
admin.initializeApp({
databaseURL: "https://project-id.firebaseio.com",
storageBucket: "project-id.appspot.com",
});
// Create Storage
const storage = admin.storage();
// Create Firestore
const firestore = admin.firestore();
// Validate image dimensions
exports.validateImageDimensions = functions
.region("us-central1")
// Increased memory, decreased timeout (compared to defaults)
.runWith({ memory: "2GB", timeoutSeconds: 120 })
.https.onCall(async (data, context) => {
// Get the image's owner
const owner = context.auth.token.uid;
// Get the image's info
const { id, description, location, tags, time } = data;
// Get the photos' bucket
const bucket = storage.bucket("photos");
...
我的服务帐户只是在Firebase控制台上生成的.json:
Project Configuration > Service Accounts > Firebase Admin SDK -> Generate Private Key
错误
当调用函数时,我得到这个错误:
{
"error": {
"code": 404,
"message": "The requested project was not found.",
"errors": [
{
"message": "The requested project was not found.",
"domain": "global",
"reason": "notFound"
}
]
}
}
有什么想法吗?
您使用的服务帐户似乎没有角色,我建议您查看此文档。
此外,这是一个常见的问题,您可以在这里检查另一个线程,并尝试一些建议的解决方法。
作为善意的提醒,我建议您检查URL是否声明https://project-id.firebaseio.com没有设置错误,当我尝试输入URL时,我得到的消息是:";未找到";。
如果这种行为持续存在,我认为你可以尝试报告你的使用情况,这里建议