Firebase身份验证模拟器电子邮件/密码登录REST端点
我可以使用此端点https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[API-KEY](在这些文档@ 部分使用电子邮件/密码登录)通过 HTTP 请求登录 Firebase 身份验证用户。
无论如何,是否可以在 Firebase 身份验证模拟器上完成此操作 - 是否有一个模拟器 REST 端点可以提供相同的功能?
当我在端口 9099 上运行身份验证模拟器时,我尝试过 -
. http://localhost:9099/v1/accounts:signInWithPassword?key=[API-KEY]
. http://localhost:9099/emulator/v1/accounts:signInWithPassword?key=[API-KEY]
. http://identitytoolkit.localhost:9099/emulator/v1/accounts:signInWithPassword?key=[API-KEY]
.http://localhost:9099/identitytoolkit/v3/relyingparty/verifyPassword?key=[API-KEY]
但没有工作。有任何想法吗?
这是我对这些请求中的每一个得到的回应 -
{
"error": {
"code": 404,
"message": "Not Found",
"errors": [
{
"message": "Not Found",
"reason": "notFound"
}
],
"status": "NOT_FOUND"
}
}
编辑:也试过这个:
http://localhost:9099/identitytoolkit.googleapis.com/v1/projects/emulator-test-project-id/accounts?key=[API-KEY]
但得到回应
{
"error": {
"code": 400,
"message": "INSUFFICIENT_PERMISSION : Only authenticated requests can specify target_project_id.",
"errors": [
{
"message": "INSUFFICIENT_PERMISSION : Only authenticated requests can specify target_project_id.",
"reason": "invalid",
"domain": "global"
}
]
}
}
回答
这个有效-
http://localhost:[PORT]/identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[API-KEY]
whereAPI-KEY可以是任何字符串,9099PORT是运行身份验证模拟器的字符串。对我来说,它默认为 9099,但您可以通过您的firebase.json(此处有更多详细信息)进行配置
- This isn't documented anywhere that I can find, and seems to work. Thank you.