How to use Firebase Auth REST API using Google Apps Script?

徘徊边缘 提交于 2019-12-08 05:11:48

问题


I am trying to sign up users on Firebase Auth using Google Apps Script via the Firebase Auth REST API.

My code looks this.

  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);

I am receving the following error.

 {
  "error": {
    "code": 400,
    "message": "ADMIN_ONLY_OPERATION",
    "errors": [
      {
        "message": "ADMIN_ONLY_OPERATION",
        "domain": "global",
        "reason": "invalid"
      }
    ]
  }
}

How do I go about this?


回答1:


Request body payload should be sent as a 'payload' property of the options object.

var payload = {
  email: "sauravo14@gmail.com",
  password: 12345678,
  returnSecureToken: true

};

 var options = {
     method: 'post',
     contentType: 'application/json',
     payload: JSON.stringify(payload)
  }; 


来源:https://stackoverflow.com/questions/56041807/how-to-use-firebase-auth-rest-api-using-google-apps-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!