Hello, not sure where to ask that. I couln’t find a way to contact a moderator.
I did 2 topics few time ago:
Now I want to edit the first one as I changed how my component work.
And I want to delete the second one.
They both show in “My activities” → “My topics”. But I don’t have the buttons to edit them. I do have the delete button but I get “you don’t have the right to delete this post”…
I’m not entirely sure why that wouldn’t be possible, but I’ll look into it. Meanwhile, I’ll delete the second post, and if you’d like to send me the sets of edits for the first post, I’d be glad to make those changes for you.
Yes please delete the JADE post. Regarding the other one, I want it to be the same as the github page with a link for it and the PyPI link like that:
Streamlit Google Auth
This package provides a simple and easy-to-use integration of Google authentication in your Streamlit application.
Getting Started
Install the package: pip install streamlit-google-auth
Create a Google Cloud Platform project and obtain the client ID and client secret. You can follow the instructions here to create the credentials.
Save the client ID and client secret in a JSON file (e.g., google_credentials.json).
Import the necessary modules and initialize the Authenticate class:
import streamlit as st
from streamlit_google_auth import Authenticate
authenticator = Authenticate(
secret_credentials_path='google_credentials.json',
cookie_name='my_cookie_name',
cookie_key='this_is_secret',
redirect_uri='http://localhost:8501',
)
Check if the user is already authenticated and handle the login/logout flow:
# Check if the user is already authenticated
authenticator.check_authentification()
# Display the login button if the user is not authenticated
authenticator.login()
# Display the user information and logout button if the user is authenticated
if not st.session_state['connected']:
st.image(st.session_state['user_info'].get('picture'))
st.write(f"Hello, {st.session_state['user_info'].get('name')}")
st.write(f"Your email is {st.session_state['user_info'].get('email')}")
if st.button('Log out'):
authenticator.logout()
That’s it! Your Streamlit app now has Google authentication integrated.
Configuration
The Authenticate class takes the following parameters:
secret_credentials_path: The path to the Google Cloud Platform credentials JSON file.
cookie_name: The name of the cookie used to store the authentication information.
cookie_key: The secret key used to encrypt the cookie.
redirect_uri: The redirect URI of your Streamlit application.
cookie_expiry_days: Optional, The number of days the cookie stay valid.
Functions
The Authenticate class provides the following functions:
check_authentification(): Catch the event when the user come back from the google login page and log it.
login(): Displays the login button and handles the authentication flow.
logout(): Logs out the user and clears the session state.
get_authorization_url(): Returns the URL for the Google authentication page.
Session State
The Authenticate class updates the following keys in the Streamlit session state:
connected: A boolean indicating whether the user is authenticated or not.
oauth_id: The unique identifier for the authenticated user.
user_info: A dictionary containing the user’s name, email, and profile picture URL.
Example
Here’s a complete example of how to use the Authenticate class in a Streamlit app:
import streamlit as st
from streamlit_google_auth import Authenticate
st.title('Streamlit Google Auth Example')
authenticator = Authenticate(
secret_credentials_path = 'google_credentials.json',
cookie_name='my_cookie_name',
cookie_key='this_is_secret',
redirect_uri = 'http://localhost:8501',
)
# Catch the login event
authenticator.check_authentification()
# Create the login button
authenticator.login()
if st.session_state['connected']:
st.image(st.session_state['user_info'].get('picture'))
st.write('Hello, '+ st.session_state['user_info'].get('name'))
st.write('Your email is '+ st.session_state['user_info'].get('email'))
if st.button('Log out'):
authenticator.logout()
Check the Github for more infos and maybe leave a star : HERE
Or the PyPI page: PyPI link
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.