Dash_auth has stopped working

Hi, Love the plotly and Dash setup but I’m struggling to add basic authorisation to my multi-page dash app. I used the example code from the dash website which worked initially for 2-3 logins but following this when I run the code it generates an exception error. The page can still be accessed but the login dropdown doesn’t appear.

My Python code is below and the error printout is attached as a screenshot. Any suggestions for sorting this error would be appreciated!

import dash
from dash import Dash, dcc, html
#import dash_core_components as dcc
#import dash_html_components as html
import dash_bootstrap_components as dbc

app = Dash(__name__, use_pages=True,external_stylesheets=[dbc.themes.BOOTSTRAP])

import dash_auth
# Keep this out of source code repository - save in a file or a database
VALID_USERNAME_PASSWORD_PAIRS = {'User': 'abc123!'}

auth = dash_auth.BasicAuth(
       app,
       VALID_USERNAME_PASSWORD_PAIRS)


# app.layout = html.Div([
#     html.H1('VAWG Analysis'),
#     html.Div([
#         html.Div(
#             dcc.Link(f"{page['name']} - {page['path']}", href=page["relative_path"])
#         ) for page in dash.page_registry.values()
#     ]),
#     dash.page_container
# ])

navbar = dbc.NavbarSimple(
    dbc.DropdownMenu(
        [
            dbc.DropdownMenuItem(page["name"], href=page["path"])
            for page in dash.page_registry.values()
            if page["module"] != "pages.not_found_404"
        ],
        nav=True,
        label="Pages",
    ),
    brand="VAWG Analysis",
    color="primary",
    dark=True,
    className="container2",
)

app.layout = dbc.Container(
    [html.Div(navbar), dash.page_container],
    fluid=True,className="create_container"
)


if __name__ == '__main__':
    app.run()#debug=True)

Hello. Hope you sorted it out since your post.

For anyone else wondering, I think it’s because the information is saved in the browser so you don’t need to enter it again.

To test the login function, you can open a new private browser window.

Hope that helps!