Hi
I have deployed my flask api on pythonanywhere. It is working fine. In order to call an api, I need to pass in the request headers which are below:
app_name: myapp
app_key : some_key
Below is the code:
@app.route('/api/app/get_id', methods=['POST'])
def get_id():
try:
if 'app_name' and 'app_key' in request.headers:
"""
SOME CODE
"""
else:
return jsonify({"status": "unauthorized", "error": "authentication parameters missing"}), 401
From above code you can see that if app_name and app_key are not present as request headers then we simply throw error. Now I am calling this API from postman:
(If image not showing, use this url: https://ibb.co/j5g9Zjm )
So I am including the app_name and app_key in postman call as headers but I am always getting error message that authentication parameters missing. I am not sure why it is happening as on local testing it was working fine.
For debugging, I also put the logging in the api code like below:
@app.route('/api/app/get_id', methods=['POST'])
def create_gallery():
try:
log.error(request.headers) ## <-- logging
if 'app_name' and 'app_key' in request.headers:
"""
SOME CODE
"""
else:
return jsonify({"status": "unauthorized", "error": "authentication parameters missing"}), 401
But in the log file also there was not app_name and app_key.
Can anyone please help me here and let me know what I am missing here. Please help. Thanks