So I’m developing an app with Flask and I’m using JWT to do the authorization, the data from the login form goes to the API, which does the verification on the db, and after it returns the authorization the front-end creates the JWT, but I don’t know how to redirect the user to the protect page while passing the auth on the header.
I’ve tried many ways but I simply don’t know how, any ideas?
The login route:
@app.route('/login', methods=['GET', 'POST'])
def login():
form = TestLogin()
if form.is_submitted():
req = requests.post('http://127.0.0.1:5000/login', json={"email": form.login.data, "senha": form.senha.data})
if req.json()['auth'] == True:
token = 'Bearer '+ str(create_access_token(identity=form.login.data))
return redirect(url_for('membros', headers={'authorization': token}))
return render_template('test.html', form=form)
The route “http://127.0.0.1:8081/membros” is protect by the decorator “@jwt_required()”