galerts / app.py
blazingbunny's picture
Update app.py
01af3f9 verified
raw
history blame
1.05 kB
import streamlit as st
from google.oauth2 import service_account
from google_auth_oauthlib.flow import Flow
import json
# Function to create Google OAuth Flow object
def create_flow():
client_secret = st.secrets["client_secret"]
return Flow.from_client_secrets_file(
client_secret,
scopes=['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email'],
redirect_uri='https://huggingface.co/spaces/blazingbunny/galerts:8501'
)
# Function to generate Google Sign-In URL
def generate_auth_url(flow):
return flow.authorization_url(
access_type='offline',
include_granted_scopes='true'
)[0]
# Function to authenticate user with Google
def authenticate_user():
flow = create_flow()
auth_url = generate_auth_url(flow)
st.write(f"[Click here to sign in with Google]({auth_url})")
# Main function to run the Streamlit app
def main():
st.title("Google Sign-In with Streamlit")
authenticate_user()
if __name__ == "__main__":
main()