My cloud functions emulator hangs when making a request to login endpoint and just on Windows. This endpoint works perfectly fine on my linux laptop. The main problem is that in windows if i send the post request in the extraction of the json it hangs, because if i get rid of that extraction the login endpoint no longer hangs.
This is the endpoint done in python with flask:
import flask
import json
import requests
import os
# Get the current directory of the script
current_directory = os.path.dirname(os.path.realpath(__file__))
# Construct the path to keys.json
keys_path = os.path.join(current_directory, "..", "..", "keys.json")
with open(keys_path) as f:
keys = json.load(f)
FIREBASE_API_KEY = keys['FIREBASE_API_KEY']
authBlueprint = flask.Blueprint('auth', __name__)
@authBlueprint.route("/login", methods=["POST"])
def login():
try:
user = flask.request.json
payload = json.dumps({"email":user['email'], "password":user['password'], "return_secure_token":True})
rest_api_url = "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword"
r = requests.post(rest_api_url,
params={"key": FIREBASE_API_KEY},
data=payload)
response = r.json()
token = response['idToken']
return flask.jsonify({"message":"Login successful","token":token}), 200
except Exception as e:
print("Error:",e)
return flask.jsonify({"message":"Failed to login"}), 500
I already checked and the headers are correct, even in my main.py I establish correctly all the allowed headers for CORS and it works. As i already told you, this only happens on Windows, on Linux (Ubuntu) works like a charm.