Flask JWT Extended “The specified alg value is not allowed” Error

让人想犯罪 __ 提交于 2020-01-24 01:16:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!