How do you solve the error KeyError: 'A secret key is required to use CSRF.' when using a wtform in flask application?

后端 未结 3 471
借酒劲吻你
借酒劲吻你 2021-02-05 02:59

I have been trying to build a web app using flask and wtforms and a firebase database, but I keep getting the error message \"KeyError: \'A secret key is required to use CSRF.\'

3条回答
  •  再見小時候
    2021-02-05 03:54

    you need to add a SECRET_KEY in the application configuration to take advantage of csrf protection and provide a WRF CSRF SECRET_KEY otherwise your secret key will be used instead

    app.config.update(dict(
        SECRET_KEY="powerful secretkey",
        WTF_CSRF_SECRET_KEY="a csrf secret key"
    ))
    

提交回复
热议问题