Closed daytonjones closed 1 year ago
Please ensure you are supplying the preauthorization argument when you are initially constructing your authenticator object as follows:
authenticator = stauth.Authenticate(
config['credentials'],
config['cookie']['name'],
config['cookie']['key'],
config['cookie']['expiry_days'],
config['preauthorized']
)
I added the "config['preauthorized']" argument as above, but now when loading the app I get:
KeyError: 'preauthorized'
Traceback:
File "/usr/local/lib/python3.6/site-packages/streamlit/scriptrunner/script_runner.py", line 475, in _run_script
exec(code, module.__dict__)
File "/home/ubuntu/DROPS/drops.py", line 37, in <module>
config['preauthorized']
Here is the full section from my app:
import streamlit_authenticator as stauth
with open ('/home/ubuntu/DROPS/.streamlit/auth_config.yaml') as file:
config = yaml.load(file, Loader=SafeLoader)
authenticator = stauth.Authenticate(
config['credentials'],
config['cookie']['name'],
config['cookie']['key'],
config['cookie']['expiry_days'],
config['preauthorized']
)
try:
if authenticator.register_user('Register User', preauthorization=False):
st.success('User registered successfully')
except Exception as e:
st.error(e)
Please make sure that you have an empty preauthorized element in your config file as shown below:
preauthorized:
emails: []
Ah... ok..thanks. Quick (final) question... can the "emails: []" contain a wildcard? I.E. ; "*.my.domain"
Not in its current implementation, but you can just leave it completely empty.
I've added a widget to allow user to register (per the doc):
try:
if authenticator.register_user('Register user', preauthorization=False):
st.success('User registered successfully')
except Exception as e:
st.error(e)
But when loading the app, I get: "Pre-authorization argument must not be None"
streamlit == 1.9.2 streamlit-authenticator == 0.2.1 OS == Ubuntu 16.04 Python == 3.6.13