从新的firebase身份验证模拟器中删除所有用户



我正在玩新的firebase auth模拟器(在节点管理SDK上(,并且已经进行了一些测试,如果我在每个测试之间手动删除创建的用户,这些测试可以完美运行,但我似乎无法自动删除它们?

我在beforeEach((中使用了这里定义的端点,但我得到了一个";响应代码401;回复电话回来了吗?

端点:删除:http://localhost:9099/emulator/v1/projects/{project-id}/accounts

我只是试着用Postman发送电话,它的回复是:

{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [
{
"message": "Login Required.",
"domain": "global",
"reason": "required",
"location": "Authorization",
"locationType": "header"
}
],
"status": "UNAUTHENTICATED"
}
}

错误中的URL似乎没有给我太多帮助,只是在网络应用程序中添加了一个谷歌按钮,这让我创建了一个OAuth2网络帐户。我在现有的中输入了localhost:9099,但不知道应该在哪里使用客户端ID和客户端机密?如果它们是我应该使用的。

我知道我需要一些用于删除调用的Authorization标头,但我只是不知道应该在该标头中放入什么,或者如何放入。

感谢您对此有任何见解。

编辑:我现在已经尝试了以下授权标头:

"管理员";

"quot;(空字符串(

firebase.options.credential.getAccessToken((生成的完整令牌

上述令牌的access_token字段

上述令牌的id_token字段。

令牌本身看起来是这样的(编辑了一些字段(:

{ 
"access_token":
"[access token string here]",
"expires_in": 3599,
"scope":
"openid https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloudplatformprojects.readonly",
"token_type": "Bearer",
"id_token":
"[id token string here]"
}

谢谢!然而,我想在npm脚本上使用curl格式,所以我使用了以下内容:

curl -H 'Authorization: Bearer owner' -X DELETE http://localhost:9099/emulator/v1/projects/<projectid>/accounts

响应应该是:

{}

我想通了!当管理员生成一个令牌时,我使用该令牌的access_token字段部分,并将头Authorization: 'Bearer' + access_token添加到删除请求中。谢谢你的帮助。

(这是一个仅限模拟器的端点(

编辑:我可以使用字符串";所有者;作为令牌。。。我花了一段时间才得到,但现在它起作用了。

最新更新