thisbejim / Pyrebase

A simple python wrapper for the Firebase API.
2.07k stars 528 forks source link

I get pyrebase authentication error 400: bad request for url:https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=AIzaSyBBkunvEMcyeoGyDNo3bCCIDUFJR2377-w #424

Open sid00100 opened 2 years ago

sid00100 commented 2 years ago

Make sure these boxes are checked before submitting your issue:

[x] Check that your version of Python is 3.4+ [x] Check that you are on the newest version of Pyrebase [x] Check that Email/password provider is enabled in your Firebase dashboard under Auth -> Sign In Method.

Please don't be discouraged if you do not get a response to your issue quickly, I maintain Pyrebase for fun and don't always have as much free time as I'd like.

Thank you for helping make Pyrebase better!

below is my route code

@app.route("/signup")
def signup():
    form = Sign_up()
    username = form.username.data
    email = form.email.data
    password = form.password.data

    user = auth.create_user_with_email_and_password(email, password)
    return render_template("signup.html", form=form)

below is the exact error that i am receiving

HTTPError
requests.exceptions.HTTPError: [Errno 400 Client Error: Bad Request for url: https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=AIzaSyBBkunvEMcyeoGyDNo3bCCIDUFJR2377-w] {
  "error": {
    "code": 400,
    "message": "ADMIN_ONLY_OPERATION",
    "errors": [
      {
        "message": "ADMIN_ONLY_OPERATION",
        "domain": "global",
        "reason": "invalid"
      }
    ]
  }
}
AsifArmanRahman commented 2 years ago

Hi there, I believe the usage of the form is incorrect and you are sending invalid data to auth.create_user_with_email_and_password() method. Try the following code to check the data you're sending into this method, which will print the data in the terminal.

@app.route("/signup")
def signup():
    form = Sign_up()
    username = form.username.data
    email = form.email.data
    password = form.password.data

    # prints data
    print(f"email: {email}, password: {password}")

    user = auth.create_user_with_email_and_password(email, password)
    return render_template("signup.html", form=form)



If you find it helpful, please consider using firebase-rest-api available in PyPI, which I recently started maintaining and adding new features as pyrebase isn't maintained anymore.

Thank you.