问题
When making a request to a flask route that requires a JWT to access using (@jwt_required
decorator on flask-restful resources), I get a 422 UNPROCESSABLE ENTITY
with the message: The specified alg value is not allowed
.
When logging in and navigating to the (frontend) route that calls the request:
this.axios.get("/jobs").then(res => {
console.log(res.data);
this.jobs = res.data.jobs;
});
in the same go, it works as expected, however on refresh it then shows the 422 error. I store the token in localstorage and load it into axios headers like so:
const api = {
init: function() {
Vue.use(VueAxios, axios);
Vue.axios.defaults.baseURL = DEV_URL;
},
setHeader: function() {
const token = `Bearer ${getToken()}`;
Vue.axios.defaults.headers.common["Authorization"] = token;
},
};
and call init()
and setHeader()
in my main.js
so I am confused why this is causing an error only after a refresh.
I haven't be able to find any resources on how to remedy the The specified alg value is not allowed
error. Any assistance would be appreciated! :)
回答1:
This can happen if the token was created using a different algorithm then app.config['JWT_ALGORITHM']
来源:https://stackoverflow.com/questions/58514171/flask-jwt-extended-the-specified-alg-value-is-not-allowed-error