Description:
A Spring Boot project exploring OAuth 2.0 authentication using Spring Security.
Implemented as part of a learning exercise by following a YouTube tutorial.
- GitHub OAuth2 login
- Google OAuth2 login
- Secured and public endpoints
- Environment variable support for client secrets
- Spring Boot 3.5.x compatible
/→ Public endpoint, accessible without login/secured→ Protected endpoint, requires OAuth2 login
- Clone the repository:
git clone https://github.com/hasnain-098/spring-security-oauth2-tutorial
cd spring-security-oauth2-tutorial- Create a
.envfile and add your secrets:
GITHUB_CLIENT_SECRET=your_github_client_secret
GOOGLE_CLIENT_SECRET=your_google_client_secret- Run the application:
./mvnw spring-boot:run- Open in browser:
- Public:
http://localhost:8080/ - Secured:
http://localhost:8080/secured→ redirects to GitHub/Google login
- Ensure your OAuth credentials are configured in the Google Cloud Console or GitHub Developer settings.
- For fresh sessions during development, use incognito mode or configure logout properly.
This project is for learning purposes only, following the YouTube tutorial:
Youtube Tutorial