Logging into Api through input

I have problem with passing login data to API with Dash. My app looks like this: I have index.py where I have two tabs with data and settings , app.py with basic configuration and apps package, where I have 2 separate modules for each tab. I have created login instance in my app.py:

server = flask.Flask(__name__)

app = dash.Dash(__name__, server=server)

app.config.suppress_callback_exceptions = True

primary_key = 'x'

private_key = 'x'

manager = Recognition(primary_key, private_key)

And made Inputs layout in settings ‘tab’:

layout = [
    html.Div([
        html.Div(
            [
                html.H3("Primary API key"),
                dcc.Input(
                    id='primary-key',
                    placeholder='Enter a value...',
                    type='text',
                    style = {"width":"50%"}
                ),
                html.H3("Private API key"),
                dcc.Input(
                    id='private-key',
                    placeholder='Enter a value...',
                    type='text',
                    style = {"width":"50%"}
                ),

                
            ],
        ),
        html.Button('Submit', id='button', className='btn btn-primary'),
        html.Div(id='output-hidden')
    ])
]



@app.callback(
    Output('output-hidden', 'children'),
    [Input('button', 'n_clicks')],
    [State('primary-key', 'value'), 
     State('private-key', 'value')]
)
def update_output(n_clicks, value1, value2):
    print(manager.api_key)
    manager.api_key = value1
    manager.api_secret = value2
    print(manager.api_key)

I imported variables from app.py etc. and what i want to do is to paste API keys into inputs, click submit and update values from app.py and it is working until I am on settings tab. When i switch to data tab keys return to it’s initial value ‘x’. What should I do to make it work as I intend?

Okay I have figured out how to solve by python way, I just added update() method to Recognition class. But I have another question how Can I make dash to remember values in Input field. For example when I put Key values into Input fields and switch tab and again back to tab where input is I want to have previously pasted keys already in input value property. Anyone can help?