Firebase Admin NodeJS SDK:TenantAwareAuth.createSessionCookie() 抛出不受支持的租户操作
Firebase Admin NodeJS SDK: TenantAwareAuth.createSessionCookie() throws unsupported tenant operation
使用 Firebase Admin SDK 实现租户感知身份验证实例时,我无法使用 following method。
代码:
// defined elsewhere: locals.tenantAuth = getAuth().tenantManager().authForTenant(tenantId)
async createSession (locals) {
try {
const { idToken, expiresIn, tenantAuth } = locals
const decodedToken = await tenantAuth.verifyIdToken(idToken, true) // this works
// Only process if the user just signed in in the last 3 minutes
if (new Date().getTime() / 1000 - decodedToken.auth_time < 3 * 60) {
return await tenantAuth.createSessionCookie(idToken, { expiresIn }) // this breaks
} else {
throw new Error('Cannot create session, sign in information is too old')
}
} catch (error) {
console.log(error)
throw new Error(error)
}
}
错误:
FirebaseAuthError: This operation is not supported in a multi-tenant context.
errorInfo: {
code: 'auth/unsupported-tenant-operation',
message: 'This operation is not supported in a multi-tenant context.'
},
codePrefix: 'auth'
版本:
- 节点:16.13.0
- Firebase 管理 SDK:10.0.0
补充:
- 方法在 tenantAware 身份验证之外工作(使用默认项目
getAuth()
)
- 在 v9 上出现同样的错误
这已作为功能请求提交。您可以通过提交的feature request link.
查看其状态
您可能需要检查此 Stack Overflow link 作为解决方法。
使用 Firebase Admin SDK 实现租户感知身份验证实例时,我无法使用 following method。
代码:
// defined elsewhere: locals.tenantAuth = getAuth().tenantManager().authForTenant(tenantId)
async createSession (locals) {
try {
const { idToken, expiresIn, tenantAuth } = locals
const decodedToken = await tenantAuth.verifyIdToken(idToken, true) // this works
// Only process if the user just signed in in the last 3 minutes
if (new Date().getTime() / 1000 - decodedToken.auth_time < 3 * 60) {
return await tenantAuth.createSessionCookie(idToken, { expiresIn }) // this breaks
} else {
throw new Error('Cannot create session, sign in information is too old')
}
} catch (error) {
console.log(error)
throw new Error(error)
}
}
错误:
FirebaseAuthError: This operation is not supported in a multi-tenant context.
errorInfo: {
code: 'auth/unsupported-tenant-operation',
message: 'This operation is not supported in a multi-tenant context.'
},
codePrefix: 'auth'
版本:
- 节点:16.13.0
- Firebase 管理 SDK:10.0.0
补充:
- 方法在 tenantAware 身份验证之外工作(使用默认项目
getAuth()
) - 在 v9 上出现同样的错误
这已作为功能请求提交。您可以通过提交的feature request link.
查看其状态您可能需要检查此 Stack Overflow link 作为解决方法。