A full-stack application demonstrating OAuth2 authentication with Google using Spring Boot and React.
- Google OAuth2 Authentication
- Spring Boot Backend (Port: 8080)
- React Frontend with Vite (Port: 5173)
- Protected Profile Page
- Sample Data Display
- Responsive Design
- Java 17
- Spring Boot 3.2.1
- Spring Security
- OAuth2 Client
- Maven
- React 18
- Vite
- React Router v6
- CSS Modules
- ESLint
- Java 17 or higher
- Node.js 16 or higher
- npm or yarn
- Google OAuth2 credentials
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API
- Create OAuth2 credentials
- Set the authorized redirect URI to:
http://localhost:8080/login/oauth2/code/google
Backend (application.yml):
spring:
security:
oauth2:
client:
registration:
google:
client-id: ${GOOGLE_CLIENT_ID}
client-secret: ${GOOGLE_CLIENT_SECRET}
-
Navigate to backend directory:
cd backend
-
Set environment variables:
export GOOGLE_CLIENT_ID=your_client_id export GOOGLE_CLIENT_SECRET=your_client_secret
-
Run the application:
./mvnw spring-boot:run
-
Navigate to frontend directory:
cd frontend
-
Install dependencies:
npm install
-
Start development server:
npm run dev
- Open
http://localhost:5173
in your browser - Click "Sign in with Google" button
- Complete Google authentication
- View your profile and sample data
ssobf/
├── backend/
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/
│ │ │ │ └── com/example/ssobf/
│ │ │ │ ├── config/
│ │ │ │ ├── controller/
│ │ │ │ └── SsobfApplication.java
│ │ │ └── resources/
│ │ │ └── application.yml
│ └── pom.xml
└── frontend/
├── src/
│ ├── pages/
│ │ ├── Login.jsx
│ │ └── Profile.jsx
│ ├── App.jsx
│ └── main.jsx
├── package.json
└── vite.config.js
- OAuth2 for secure authentication
- CORS configuration for frontend-backend communication
- Environment variables for sensitive data
backend:
8080, spring boot, google callback url: http://localhost:8080/login/oauth2/code/google
frontend:
5173, vite react.js, login page and profile page, sample data array