【问题标题】:How to use Firebase Auth REST API using Google Apps Script?如何使用 Google Apps 脚本使用 Firebase Auth REST API?
【发布时间】:2019-05-08 21:59:53
【问题描述】:

我正在尝试通过 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"
      }
    ]
  }
}

我该怎么做?

【问题讨论】:

    标签: firebase google-apps-script firebase-authentication


    【解决方案1】:

    请求正文有效负载应作为 options 对象的“有效负载”属性发送。

    var payload = {
      email: "sauravo14@gmail.com",
      password: 12345678,
      returnSecureToken: true
    
    };
    
     var options = {
         method: 'post',
         contentType: 'application/json',
         payload: JSON.stringify(payload)
      }; 
    

    【讨论】:

    • 完美运行。谢谢!!
    • @user2176475 很高兴听到它有帮助。您能否将问题标记为已解决?
    猜你喜欢
    • 2014-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-29
    • 1970-01-01
    • 1970-01-01
    • 2016-03-23
    • 1970-01-01
    相关资源
    最近更新 更多