Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Access Flask rendered html template within JWT protected environment

I already managed to set up a working user authentication with Flask JWT.

With a button click I'm sending user and password to my login endpoint and with correct credentials I will get back an access_token and store that in my browser storage

$("#buttonid").click(function () {
            var person = {
                username: $("#userid").val(),
                password: $("#passwordid").val(),
            };

            $.ajax({
                url: "/login",
                type: "post",
                dataType: "json",
                contentType: "application/json",
                data: JSON.stringify(person),

                success: function (data) {
                    localStorage.setItem("token", data.access_token);       
                },
            });
    

Together with that button click I would like to access my jwt_restricted protected.html

@app.route("/protected", methods=["GET", "POST"])
@jwt_required()
def protected():
       return render_template("protected.html")

Cause of jwt_required I'm transfering the saved token in my header, that works within ajax, but doesnt load my protected.html.

$.ajax({
          url: "/protected",
          type: "get",
          headers: { Authorization: "Bearer " + localStorage.getItem("token")},
          success: function (response) 
              {console.log("working");},
      });

Is it possible to send my token in a get request from within a page load something like

window.location.href = "protected" (headers: { Authorization: "Bearer " + localStorage.getItem("token"));

Or is there any other way?

Thx

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!