First you need to generate the csrf token from the server, and the client can get it through a simple request, and then pass it back in the mail request. You can use the method below to create a token.
flask_wtf.csrf.generate_csrf(secret_key=None, time_limit=None)
For instance,
@app.route('/token')
def token():
token=generate_csrf(time_limit=10)
return jsonify({'token':token}), 201
Then send a request with a heading 'X-CSRFToken'
source
share