I’ve used a st.components.v1.iframe to integrate an authentication mechanism that sends back a token to the parent if the user is allowed to authenticate, the iframe content looks like this:
<script src="remote/auth.js"></script>
<script>
token = window.getAuth();
parent.postMessage(token, '*');
</script>
and in the streamlit app:
from streamlit.components.v1 import html, iframe
html("""
<script>
parent.window.addEventListener('message', e => {
const key = e.message ? 'message' : 'data';
const token = e[key];
parent.window.token = token;
},false);
</script>
""")
iframe("RemoteIframeLocation")
Now what I want is to send back the parent.window.token
to the python back-end in order to grant access to users based on the token.
I’m aware that basically this should be possible with bi-directional streamlit components, but it seems like it’s way too complicated and an overkill for my use case where I only need to send one value !