Error 400 with flask-login only in browser
<p>I'm building a login for a web application using the framework flask and the extension flask-login. Using an HTTP client like <a href="https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop" rel="nofollow">Postman</a> to make http request to my api, everything work perfectly, but when I try it into the browser, it always return error 400. Here's the code:  </p>

<pre><code>@app.route('/api/protected')
@flask_login.login_required
def protected():
    #return flask_login.current_user.id + " is now logged in"
    return redirect('site-to-interface.html', code=302)


@app.route('/api/login', methods=['POST'])
def login():
    email = request.form['email']
    passwd = request.form['passwd']
    data = getUsersData()
    for key in data:
        if(email == data[key]["email"] and passwd == data[key]["pass"]):
            user = User()
            user.id = email
            flask_login.login_user(user, remember=True)
            return redirect(url_for('protected'))

    return jsonify(
        {"message": "authentication failed" }
    ), 401  
</code></pre>

<p>The first call to <code>/api/login</code> works and 302 is returned correctly, but when it calls <code>/api/protected</code> (in the browser), it returns 400 BAD REQUEST instead of redirect to the specified location. How can I solve?</p>