I am creating a login system and using Flask-JWT-Extended in my project. However, when I wanted to create a HS256 secret key to encode my JWT, I couldn't find any proper way to do this. Is there any suitable way to do this in Python, Flask? Thanks in advance.
Asked
Active
Viewed 2,827 times
1 Answers
0
When you set the configuration options in the flask app
# Example from flask-jwt-extended docs
app = Flask(__name__)
# Setup the Flask-JWT-Extended extension
app.config["JWT_SECRET_KEY"] = "super-secret" # Change this!
jwt = JWTManager(app)
you can also add the config option JWT_ALGORITHM
e.g.
app.config["JWT_ALGORITHM"] = "HS256"
The rest of the basic usage tutorial will show you how to actually create the token.
See docs for this config option and others here

JJ Hassan
- 395
- 3
- 11
-
1Thanks. But how does this 'super-secret' come about? What would you recommend if I want to generate random? – ned Feb 10 '22 at 14:15
-
1A good answer for this is here: https://stackoverflow.com/a/54433731/8903959 – Justin Furuness Feb 17 '23 at 06:35