Is there a mechanism that works to get the client IP address ( internet) and device details like OS / browser etc. to implement security for users , how can this be implemented i tried a few ways (ipify.org etc.) but it returns localhost/127.0.0.1 for me always. On hosting the code on the server it returns the server IP Address.
Browser: access the User-Agent
exposed by st.context.headers
. Here is some docs on what to do and how to interpret user agent information:
IP address: there is an old discussion on GitHub Log connected IPs and client information to console and/or file · Issue #602 · streamlit/streamlit · GitHub. In a nutshell, Streamlit does not support getting that information natively.
Thanks this was helpful. getting client side IP seems to be an issue
I found that Streamlit uses Tornado as its backend. You can add the following line to the __init__
method in RequestHandler
self.request.headers.add("ip", self.request.remote_ip)
Then, you can retrieve the IP address from the headers using:
st.context.headers.get('ip')
Helpful
From version 1.45.0, you can use st.context.ip_address
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.