I am running an FLASK app where I check the JWT in the index endpoint. The problem was I get 2 response when I execute this end point .
127.0.0.1 - - [06/Dec/2018 17:38:21] "GET / HTTP/1.1" 302 -
127.0.0.1 - - [06/Dec/2018 17:38:21] "GET /home HTTP/1.0" 200 -
My code is
@app.route('/')
def index():
try:
encoded_jwt=request.headers.get('jwt')
print(encoded_jwt)
secret = "-----BEGIN PUBLIC KEY----- ........"
claims = jwt.decode(encoded_jwt, secret)
print(type(claims))
import json
json_parse = json.loads(json.dumps(claims))
email = json_parse['http://wso2.org/claims/emailaddress']
print(email)
roles = json_parse['http://wso2.org/claims/role']
print(roles)
session['email'] = email
if ROLETAGOFADMIN in roles:
role="admin"
elif "" in roles:
role = "employee"
else:
role=None
session['role'] = role
if 'email' in session and (session['role'] == "admin" or session['role'] == "employee" )and request.method == "GET":
if 'lastpage' in session:
lastpage=session['lastpage']
print(lastpage)
session.pop('lastpage')
return redirect(lastpage)
else:
return redirect(url_for('home'))
else:
return "Sorry. Unfortunately You have no access."
except Exception as e:
return redirect(url_for('error'))
My Identity server is redirecting because of the first response. I couldn't find the way to fix that. I am not aware of that the error is occurred because of the try catch . Please help me.