This guide will help you set up OAuth authentication for TalkHeal using Google, GitHub, and Microsoft providers.
- Python 3.8+
- Streamlit
- OAuth provider accounts (Google, GitHub, Microsoft)
Create a .env file in the TalkHeal directory with the following variables:
# OAuth Configuration
OAUTH_REDIRECT_URI=http://localhost:8501/oauth_callback
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id_here
GOOGLE_CLIENT_SECRET=your_google_client_secret_here
# GitHub OAuth
GITHUB_CLIENT_ID=your_github_client_id_here
GITHUB_CLIENT_SECRET=your_github_client_secret_here
# Microsoft OAuth
MICROSOFT_CLIENT_ID=your_microsoft_client_id_here
MICROSOFT_CLIENT_SECRET=your_microsoft_client_secret_here- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API
- Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client IDs"
- Set application type to "Web application"
- Add authorized redirect URIs:
http://localhost:8501/oauth_callback?provider=google(for development)https://yourdomain.com/oauth_callback?provider=google(for production)
- Copy the Client ID and Client Secret to your
.envfile
- Go to GitHub Developer Settings
- Click "New OAuth App"
- Fill in the application details:
- Application name: TalkHeal
- Homepage URL:
http://localhost:8501(or your domain) - Authorization callback URL:
http://localhost:8501/oauth_callback?provider=github
- Click "Register application"
- Copy the Client ID and Client Secret to your
.envfile
- Go to Azure Portal
- Navigate to "Azure Active Directory" → "App registrations"
- Click "New registration"
- Fill in the details:
- Name: TalkHeal
- Supported account types: "Accounts in any organizational directory and personal Microsoft accounts"
- Redirect URI: Web -
http://localhost:8501/oauth_callback?provider=microsoft
- Click "Register"
- Go to "Certificates & secrets" → "New client secret"
- Copy the Application (client) ID and Client Secret to your
.envfile
- Install the required dependencies:
pip install -r requirements.txt-
Set up your environment variables in
.envfile -
Run the application:
streamlit run TalkHeal.py- Google OAuth: Sign in with Google account
- GitHub OAuth: Sign in with GitHub account
- Microsoft OAuth: Sign in with Microsoft account
- Guest Login: Continue without authentication
- Traditional Login: Email/password authentication
- Secure state parameter validation
- CSRF protection
- Token expiration handling
- User data normalization across providers
- Secure session management
- "OAuth provider not configured": Check your
.envfile and ensure all required variables are set - "Invalid redirect URI": Ensure your redirect URI matches exactly what you configured with the OAuth provider
- "Access denied": Check if the OAuth app is properly configured and the user has granted permissions
- Development: Use
http://localhost:8501as your base URL - Production: Update all redirect URIs to use your production domain
- HTTPS: OAuth providers require HTTPS in production
You can customize the OAuth providers by modifying auth/oauth_config.py:
- Add new providers
- Modify scopes
- Change redirect URIs
- Update user data mapping
For issues related to OAuth setup, please check:
- OAuth provider documentation
- Streamlit OAuth documentation
- Application logs for detailed error messages