A simple Flask application that demonstrates how to implement Google OAuth 2.0 authentication.
This project helps you integrate Google login into your Flask apps securely and easily.
- Google OAuth 2.0 authentication
- User login with Google account
- Fetch and display user profile information (name, email, profile picture)
- Flask session management
- Beginner-friendly and easy to extend
flask_google_oauth/
│── app.py # Main Flask application
│── client_secret.json # Google OAuth credentials (keep this private!)
│── templates/ # HTML templates
│ ├── index.html
│ ├── profile.html
│── static/ # Static files (CSS, JS, images)
│── venv/ # Virtual environment (not uploaded to GitHub)
│── requirements.txt # Project dependencies
│── README.md # Project documentation
git clone https://github.com/your-username/flask_google_oauth.git
cd flask_google_oauth
python -m venv venv
source venv/bin/activate # On macOS/Linux
venv\Scripts\activate # On Windows
pip install -r requirements.txt
- Go to Google Cloud Console.
- Create a new project (or select an existing one).
- Navigate to APIs & Services → Credentials.
- Create OAuth 2.0 Client ID for a Web Application.
- Add the following Authorized redirect URI:
http://127.0.0.1:5000/callback
- Download the
client_secret.json
file and place it in the project root.
python app.py
Now open http://127.0.0.1:5000 in your browser.
- Never upload your
client_secret.json
to GitHub. - Use environment variables or secret managers in production.
- Restrict OAuth credentials in Google Cloud Console to trusted domains only.
Pull requests are welcome!
If you’d like to improve this project, please fork the repo and submit a PR.
This project is licensed under the MIT License – see the LICENSE file for details.