【发布时间】:2023-04-04 04:55:01
【问题描述】:
我一直在尝试为我的应用程序添加对多租户的支持。
我是这样初始化的
const app = firebase.initializeApp();
const tenantManager = app.auth().tenantManager();
const tenant = await tenantManager.createTenant({ displayName: `test- tenant` });
const auth = tenantManager.authForTenant(tenantId);
我的应用程序的一部分然后使用auth.createCustomToken(uid) 来创建一个令牌,然后可以将其交换为标准 id 令牌(使用其余端点 /accounts:signInWithCustomToken。
尝试创建自定义令牌时出现以下错误
Error: This operation is not supported in a multi-tenant context
此外,手动创建令牌(使用jsonwebtoken 和服务帐户密钥)时会出现错误
Specified tenant ID does not match the custom token
在尝试验证令牌时出现(通过 REST API)
是否有其他人遇到此错误,或者是否有人知道在多租户环境中生成和验证自定义令牌的另一种方法(或者,知道某种方法可以仅在给定 uid 的情况下让用户登录)?
【问题讨论】:
-
你是通过什么方式指定谷歌服务帐号的?
-
通过 GOOGLE_ACCOUNT_CREDENTIALS 环境变量
标签: firebase google-cloud-platform firebase-authentication