mkhorasani/Streamlit-Authenticator

authenticator.login() is takes too much time

drawdehe opened this issue · 5 comments

Hi,

First of all, thank you for writing this code.

I have a problem though, which is that the authenticator.login() takes a bit too much time. When loading the streamlit page, it takes about 2 seconds to load the login form, which I think is a bit too slow.

Writing this code, the time between print(3) and print(4) is really long.

print(1)

with open('config.yaml') as file:
    config = yaml.load(file, Loader=SafeLoader)
            
print(2)

authenticator = stauth.Authenticate(
    config['credentials'],
    config['cookie']['name'],
    config['cookie']['key'],
    config['cookie']['expiry_days'],
    config['pre-authorized']
)

print(3)
    
authenticator.login()

print(4)

Hence, I would be able to speed up the authenticator.login() call. Is it possible?

Thank you!

Hi @drawdehe, thank you for reaching out. This problem has been brought up before #152, therefore I am going to close this issue and request that you kindly follow the other. Please note that the time taken to login is largely due to the package attempting to retrieve the re-authentication cookie. While I have no solution yet, this is something in the backlog and I hope to address it promptly. Cheers.

Thank you! Following that issue instead. :)

One solution could be to add the option of disabling cookies maybe?

One solution could be to add the option of disabling cookies maybe?

Yeap, will do!

Guys, the reason why the login button is rendering so long is because of default sleep_time = 1.0.
Change it to 0 and it will render much faster.

authenticator.login(
sleep_time=0
)