[Python] Login issue when using Firebase auth by pyrebase4(sign_in_with_email_and_password...

Discussão em 'Python' iniciado por Stack, Março 14, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Firebase's Firestore and have built a backend API server using FastAPI. I am also using Firebase's login feature with the Pyrebase4 library (referenced from: https://github.com/nhorvath/Pyrebase4/blob/master/README.md). After deployment, around 10 company employees accessed and used it simultaneously, but at some point, the login stopped working. Currently, I suspect that the sign_in_with_email_and_password function in Pyrebase4, which handles login, is causing the issue when sending login requests. However, I am having trouble finding information related to request limits or traffic, so I am reaching out for help.

    If you need any adjustments or additional information, feel free to let me know!

    The client's request is successfully received by the backend, but it returns a 401 Unauthorized error. Since everyone was using it without issues until suddenly it stopped working, I'm not sure what the reason is. The function provided by Pyrebase4 is as follows:

    def sign_in_with_email_and_password(self, email, password):
    request_ref = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key={0}".format(self.api_key)
    headers = {"content-type": "application/json; charset=UTF-8"}
    data = json.dumps({"email": email, "password": password, "returnSecureToken": True})
    request_object = requests.post(request_ref, headers=headers, data=data)
    raise_detailed_error(request_object)
    self.current_user = request_object.json()
    return request_object.json()


    I'm calling it like this: user = fire_auth.sign_in_with_email_and_password(form_data.username, form_data.password) When I call it through Swagger, it returns "Invalid email or password."

    Please help me! ;(

    Continue reading...

Compartilhe esta Página