Hi all, 

My GAE flask web app works fine without any auth, but when I try to add 
basic authentication, it starts to produce 502 Bad Gateway error. Looked 
into GAE logs, found error: 

> from flask_httpauth import HTTPBasicAuth
ModuleNotFoundError: No module named 'flask_httpauth'

Ok, the module might be not installed yet, so: 

> $ pip3 install flask_httpauth
Requirement already satisfied: flask_httpauth in 
./.local/lib/python3.7/site-packages (4.2.0)
Requirement already satisfied: Flask in 
/usr/local/lib/python3.7/dist-packages (from flask_httpauth) (1.1.2)
Requirement already satisfied: click>=5.1 in 
/usr/local/lib/python3.7/dist-packages (from Flask->flask_httpauth) (7.0)
Requirement already satisfied: Werkzeug>=0.15 in 
/usr/local/lib/python3.7/dist-packages (from Flask->flask_httpauth) (1.0.1)
Requirement already satisfied: itsdangerous>=0.24 in 
/usr/local/lib/python3.7/dist-packages (from Flask->flask_httpauth) (1.1.0)
Requirement already satisfied: Jinja2>=2.10.1 in 
/usr/local/lib/python3.7/dist-packages (from Flask->flask_httpauth) (2.11.2)
Requirement already satisfied: MarkupSafe>=0.23 in 
/usr/local/lib/python3.7/dist-packages (from 
Jinja2>=2.10.1->Flask->flask_httpauth) (1.1.1)

As you can see, it was already installed before. 

Just in case, installed it for pip (not only for pip3)

> $ pip install flask_httpauth

After that I tried to call my web app again 

https://example.com?who=test1234567

but it produces the same error as above. 

My main.py code: https://pastebin.com/CNzmgQ5c
(also its code is below for your convenience)

Please advise. 


import flask
from flask import Flask
from flask import jsonify
from Flask_HTTPAuth import HTTPBasicAuth
app = flask.Flask(__name__)
auth = HTTPBasicAuth()
@app.route("/", methods=["GET"])
def hello():
        who = flask.request.args.get("who", "World")
        return f"Hello {who}!\n"
@app.route('/rest-auth')
@auth.login_required
def get_response():
        return jsonify('You are authorized to see this message')
@auth.verify_password
def authenticate(username, password):
        if username and password:
                if username == 'test' and password == '2345':
                        return True
                else:
                        return False
        return False
if __name__ == "__main__":
    app.run(host="localhost", port=8080, debug=True)


-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/e7b3c635-add3-47a1-a1d5-84e114083107n%40googlegroups.com.

Reply via email to