我正在尝试通过Firebase Auth REST API使用Google Apps脚本在Firebase Auth上注册用户。
我的代码看起来像这样。
var apiKey = "XXXX";
var url = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=" + apiKey;
var options = {
method: 'post',
contentType: 'application/json',
email: "email@gmail.com",
password: "12345678",
returnSecureToken: true
};
var response = UrlFetchApp.fetch(url, options);
我正在纠正以下错误。
{
"error": {
"code": 400,
"message": "ADMIN_ONLY_OPERATION",
"errors": [
{
"message": "ADMIN_ONLY_OPERATION",
"domain": "global",
"reason": "invalid"
}
]
}
}
我该怎么办?
答案 0 :(得分:2)
请求正文有效负载应作为 options 对象的“有效负载”属性发送。
var payload = {
email: "sauravo14@gmail.com",
password: 12345678,
returnSecureToken: true
};
var options = {
method: 'post',
contentType: 'application/json',
payload: JSON.stringify(payload)
};