This is a simple OAuth authentication server that allows users to log in using GitHub or Google.
It retrieves their profile information after login and securely stores an access token in a cookie for 60 seconds.
Protected routes ensure that only authenticated users can access certain endpoints.
- Frontend: React.js
- Backend: Express.js
- OAuth Providers: GitHub & Google
- Database: No database (Session-based authentication)
- Express.js: Handles API requests and authentication flow.
- Axios: Makes requests to GitHub/Google APIs.
- CORS: Enables frontend-backend communication.
- Cookie-Parser: Reads cookies from incoming requests.
- dotenv: Manages environment variables.
✅ Login with GitHub and Google
✅ Retrieve user profile details
✅ Store access token securely in cookies (valid for 60 seconds)
✅ Protect certain routes (e.g., /profile) for authenticated users
✅ Handle logout functionality
- Navigate to the
backendfolder:cd backend - Install dependencies:
npm install
- Create a
.envfile and add the following:GITHUB_CLIENT_ID=your_github_client_id GITHUB_CLIENT_SECRET=your_github_client_secret GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret FRONTEND_URL=http://localhost:3000
- Start the backend server:
npm start
- Navigate to the
frontendfolder:cd ../frontend - Install dependencies:
npm install
- Start the frontend:
npm start
- User clicks Login with GitHub or Login with Google on the frontend.
- The backend redirects them to the OAuth provider’s login page.
- After authentication, the provider returns an authorization code.
- The backend exchanges this code for an access token and retrieves user data.
- The backend stores the token in a secure HTTP-only cookie for 60 seconds.
- The user can now access protected routes (e.g.,
/profile). - Logout removes the session and clears the cookie.
We welcome contributions!
Follow these steps to contribute:
- Fork the repository
- Create a new branch:
git checkout -b feature-branch
- Make changes and commit:
git commit -m "Added a new feature" - Push to the branch:
git push origin feature-branch
- Open a Pull Request
If you like this project, give it a ⭐ on GitHub! 😊


