- Make username login case-insensitive (Dvir = dvir = DVIR) - Add Google OAuth login/signup functionality - Install required dependencies (authlib, httpx, python-dotenv) - Create OAuth endpoints: /auth/google/url, /auth/google/callback - Add Google login button to frontend with styled UI - Configure environment variables for OAuth credentials - Add comprehensive setup documentation - Secure .env file with .gitignore
3.3 KiB
3.3 KiB
Google OAuth Setup Guide
Prerequisites
- A Google Cloud Platform account
- A project created in Google Cloud Console
Step 1: Create OAuth 2.0 Credentials
- Go to Google Cloud Console
- Select your project (or create a new one)
- Navigate to APIs & Services > Credentials
- Click Create Credentials > OAuth 2.0 Client ID
- If prompted, configure the OAuth consent screen:
- Choose External user type
- Fill in the required fields:
- App name: Tasko
- User support email: Your email
- Developer contact information: Your email
- Add scopes (optional):
userinfo.email,userinfo.profile - Add test users if needed
- Select Application type: Web application
- Add Authorized redirect URIs:
- For local development:
http://localhost:8000/auth/google/callback - For production:
https://your-domain.com/auth/google/callback
- For local development:
- Click Create
- Copy the Client ID and Client Secret
Step 2: Configure Backend
-
Copy
.env.exampleto.envin the backend directory:cd backend cp .env.example .env -
Edit
.envand add your Google OAuth credentials:GOOGLE_CLIENT_ID=your_client_id_here.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=your_client_secret_here GOOGLE_REDIRECT_URI=http://localhost:8000/auth/google/callback FRONTEND_URL=http://localhost:5173 -
For production, update the URLs:
GOOGLE_REDIRECT_URI=https://api.tasko.dvirlabs.com/auth/google/callback FRONTEND_URL=https://tasko.dvirlabs.com
Step 3: Install Dependencies
cd backend
pip install -r requirements.txt
Step 4: Test the Setup
-
Start the backend server:
cd backend uvicorn main:app --reload -
Start the frontend:
cd frontend npm run dev -
Open your browser and navigate to the frontend URL
-
Click "Continue with Google" button
-
Complete the Google authentication flow
Features Implemented
1. Case-Insensitive Username Login
- Users can now login with usernames in any case (e.g., "Dvir", "dvir", "DVIR" all work)
- Registration checks for existing usernames case-insensitively to prevent duplicates
2. Google OAuth Integration
- Users can sign up and login using their Google account
- New users are automatically created with:
- Username derived from email (before @)
- Email from Google account
- Default task lists (Personal, Work, Shopping)
- Existing users (matched by email) can login with Google
- Seamless redirect back to the application after authentication
Troubleshooting
"redirect_uri_mismatch" Error
- Ensure the redirect URI in Google Cloud Console exactly matches the one in your
.envfile - Include the protocol (http/https), domain, port, and full path
"Access blocked" Error
- Add your email as a test user in the OAuth consent screen
- If published, ensure your app is verified by Google
"Invalid credentials" Error
- Check that your
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETare correct - Ensure there are no extra spaces or quotes in the
.envfile
Security Notes
- Never commit your
.envfile to version control - Keep your
GOOGLE_CLIENT_SECRETsecure - Use HTTPS in production
- Regularly rotate your OAuth credentials
- Review and limit the OAuth scopes to only what's needed