Python 当将Kong与oauth2一起使用时,如何使用flask后端向Dash plotly应用程序添加身份验证标头?

Python 当将Kong与oauth2一起使用时,如何使用flask后端向Dash plotly应用程序添加身份验证标头?,python,python-3.x,flask,plotly-dash,kong,Python,Python 3.x,Flask,Plotly Dash,Kong,我已经使用Kong oauth2插件在我的烧瓶背景Dash plotly应用程序上设置了身份验证。我想将身份验证标头发送到/dash路由上的我的dash应用程序。我尝试通过resp头中的flask后端发送相同的内容 from flask import Blueprint, Flask, flash, render_template, request, jsonify, Response, redirect, make_response, url_for, session from flask_c

我已经使用Kong oauth2插件在我的烧瓶背景Dash plotly应用程序上设置了身份验证。我想将身份验证标头发送到/dash路由上的我的dash应用程序。我尝试通过resp头中的flask后端发送相同的内容

from flask import Blueprint, Flask, flash, render_template, request, jsonify, Response, redirect, make_response, url_for, session
from flask_cors import CORS, cross_origin
from .. import server
import requests, logging, json, ast

login_controller = Blueprint(
    'login_controller', __name__, template_folder='templates')


def check(username, password):
    # test case
    if(username == "admin" and password == "admin"):
        session['logged_In'] = True
        val = '1'
    else:
        flash("Invalid Username or/and password")
        val = None

    return val


@login_controller.route("/login", methods=['POST'])
def login():
    if(request.method == 'POST'):
        error = None
        val = check(request.form['username'], request.form['password'])
        if session.get("logged_In") and val:
            # kong access token will be available here
            Session[KONG_ACCESS_TOKEN]
            resp = make_response(redirect("/dash"))
            resp.headers['Authorization'] = "Bearer "+KONG_ACCESS_TOKEN
            resp.set_cookie("login_auth", val, 60*15)
            logging.info("Authentication successful")
            return resp
        else:
            resp = make_response(redirect("/"))
            logging.info("Authentication failed")
            return resp
我正确地从登录路由在resp中获取了头,但它没有显示在请求头中,并且在重定向到/dash时得到了未经授权的响应

这里是Dash应用程序的my app.py

import flask, os, dash, logging
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
from ..server import server
from logging.handlers import RotatingFileHandler

external_stylesheets = [
    "some stylesheets"
]
df = pd.read_csv(open(os.path.abspath(
    "example.csv")), 'r', delimiter=',')
logging.info('Dash Application launched on Flask server')
app = dash.Dash(__name__, server=server,
                external_stylesheets=external_stylesheets, url_base_pathname="/dash")
app.config.suppress_callback_exceptions = True

data = df.copy()

def indicator(text, id_value, size):
    return html.Div(
        [
            html.Div(
                text,
                className="class1"
            ),
            html.Div(
                id_value,
                id=text,
                className="class2"
            ),
        ],
        className=size,
    )

感谢您在这方面的帮助。

面对同样的问题。如果有人知道出路,请分享