当我使用httpclientfactory调用firebase signupNewUser端点时,出现400错误。我正在从Postman(相关)调用我的应用程序。这是我的dotnet代码:
var stringPayload = await Task.Run(() => JsonConvert.SerializeObject(loginObject));
var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");
using (var client = _client.CreateClient())
{
var uri = _firebaseUrl + "/signupNewUser?key=" + _apiKey;
var httpResponse = await client.PostAsync(uri, httpContent);
if (httpResponse.Content != null)
{
var responseContent = await httpResponse.Content.ReadAsStringAsync();
}
调试代码时,responseContent
是这样的:
{
"error": {
"code": 400,
"message": "ADMIN_ONLY_OPERATION",
"errors": [
{
"message": "ADMIN_ONLY_OPERATION",
"domain": "global",
"reason": "invalid"
}
]
}
}
但是,如果我从调试器复制了确切的uri(以确保正确地从配置中抓取了apiKey
),并从原始邮递员调用中获取了完全相同的json正文,并直接调用了Firebase网址,我可以创建一个用户。我不知道我在做什么错。