{"id":48774026,"url":"https://github.com/mohdajmalraza/oauth-server","last_synced_at":"2026-04-13T12:01:37.888Z","repository":{"id":298707851,"uuid":"1000841368","full_name":"mohdajmalraza/oauth-server","owner":"mohdajmalraza","description":" A lightweight Node.js OAuth2 backend for handling Google and GitHub login using Express and Axios. ","archived":false,"fork":false,"pushed_at":"2025-06-14T18:49:36.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-01T18:26:41.429Z","etag":null,"topics":["axios","express-js","github-login","github-oauth2","gmail-login","google-oauth2","node-js"],"latest_commit_sha":null,"homepage":"https://oauth-server-tau.vercel.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mohdajmalraza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-12T12:03:23.000Z","updated_at":"2025-06-14T18:49:40.000Z","dependencies_parsed_at":"2025-06-12T13:25:29.904Z","dependency_job_id":"156e2b15-db71-4c9c-83c1-f0fb69c289c8","html_url":"https://github.com/mohdajmalraza/oauth-server","commit_stats":null,"previous_names":["ajmal92786/oauth-server","mohdajmalraza/oauth-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mohdajmalraza/oauth-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohdajmalraza%2Foauth-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohdajmalraza%2Foauth-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohdajmalraza%2Foauth-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohdajmalraza%2Foauth-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohdajmalraza","download_url":"https://codeload.github.com/mohdajmalraza/oauth-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohdajmalraza%2Foauth-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31751705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axios","express-js","github-login","github-oauth2","gmail-login","google-oauth2","node-js"],"created_at":"2026-04-13T12:01:37.185Z","updated_at":"2026-04-13T12:01:37.852Z","avatar_url":"https://github.com/mohdajmalraza.png","language":"JavaScript","readme":"# 🛡️ OAuth Server - GitHub \u0026 Google Login\n\n![Node.js](https://img.shields.io/badge/Node.js-18.x-green?logo=node.js)\n![Express](https://img.shields.io/badge/Express.js-Backend-lightgrey?logo=express)\n![Vercel](https://img.shields.io/badge/Deployed%20on-Vercel-black?logo=vercel)\n\n\u003c!--\n![License](https://img.shields.io/badge/License-MIT-blue)\n--\u003e\n\nA minimal and secure OAuth 2.0 server built with **Node.js**, **Express**, and **Axios** to handle GitHub and Google login flows, cookie-based token management, and profile retrieval.\n\n---\n\n## 🚀 Live Demo\n\n| Platform  | Frontend                                            | Backend                                          |\n| --------- | --------------------------------------------------- | ------------------------------------------------ |\n| 🔗 GitHub | [Frontend](https://oauth-frontend-eac27.vercel.app) | [Backend](https://oauth-server-eac27.vercel.app) |\n\n---\n\n## 📋 Table of Contents\n\n- [Features](#-features)\n- [Technologies Used](#-technologies-used)\n- [How OAuth Flow Works](#-how-oauth-flow-works)\n- [Run Locally](#-run-locally)\n- [Environment Variables](#-environment-variables)\n- [Test the App](#-test-the-app)\n- [Folder Structure](#-folder-structure)\n- [License](#-license)\n\n---\n\n## ✨ Features\n\n- 🔒 OAuth 2.0 login with GitHub \u0026 Google\n- 🍪 Secure cookie handling with `httpOnly`, `secure`, and `SameSite`\n- 🧠 Token verification middleware\n- 📥 Clean API endpoints to fetch user profiles\n- 🌍 Deployed on Vercel\n\n---\n\n## 🛠 Technologies Used\n\n- **Node.js** \u0026 **Express**\n- **Axios** for HTTP requests\n- **cookie-parser** for cookie handling\n- **dotenv** for environment config\n- **Vercel** for deployment\n\n---\n\n## 🔄 How OAuth Flow Works\n\n1. User clicks \"Login with GitHub\" or \"Login with Google\" on frontend.\n2. Frontend redirects user to backend (`/auth/github` or `/auth/google`).\n3. Backend redirects user to the GitHub or Google OAuth consent screen.\n4. After consent, the provider redirects back to backend with a `code`.\n5. Backend uses that `code` to request an `access_token`.\n6. `access_token` is stored in secure `httpOnly` cookie.\n7. Frontend calls `/user/profile/github` or `/user/profile/google` to get user info.\n\n\u003e 🔁 The OAuth flow uses environment variables to dynamically construct the authorization and token exchange URLs.\n\u003e\n\u003e - `GOOGLE_REDIRECT_URI` is used in:\n\u003e\n\u003e   - The initial redirect to Google’s OAuth consent screen\n\u003e   - The server-side token exchange (`/auth/google/callback`)\n\u003e\n\u003e - `GITHUB_REDIRECT_URI` is recommended for consistency.\n\n---\n\n## 🧑‍💻 Run Locally\n\n### Clone the repo:\n\n```bash\ngit clone https://github.com/ajmal92786/oauth-server.git\ncd oauth-server\nnpm install\nnpm start\n```\n\n### Related Frontend Repo\n\nTo test the backend via UI, clone the frontend:\n\n```bash\ngit clone https://github.com/ajmal92786/oauth-frontend.git\ncd oauth-frontend\nnpm install\nnpm run dev\n```\n\nMake sure:\n\n- Backend is running on: `http://localhost:4000`\n- Frontend is running on: `http://localhost:3000`\n\n---\n\n## 🧾 Environment Variables\n\n### 📌 `.env` for `oauth-server`:\n\n```env\nPORT=4000\nFRONTEND_URL=http://localhost:3000\n\n# GitHub OAuth\nGITHUB_CLIENT_ID=your_github_client_id\nGITHUB_CLIENT_SECRET=your_github_client_secret\n\n# Google OAuth\nGOOGLE_CLIENT_ID=your_google_client_id\nGOOGLE_CLIENT_SECRET=your_google_client_secret\n\n# Redirect URIs\nGOOGLE_REDIRECT_URI=http://localhost:4000/auth/google/callback\n```\n\n### 📌 `.env` for `oauth-frontend`:\n\n```env\nVITE_SERVER_BASE_URL=http://localhost:4000\nVITE_GITHUB_API_BASE_URL=https://api.github.com\n```\n\n📁 Also provide a `.env.example` for contributors.\n\n---\n\n## 🧪 Test the App\n\n- Visit the frontend: [oauth-frontend.vercel.app](https://oauth-frontend-eac27.vercel.app)\n- Click “Login with GitHub” or “Login with Google”\n- Authorize the app\n- Your profile info will be fetched via backend and displayed on the frontend\n\n---\n\n## 📂 Folder Structure\n\n```\noauth-server/\n├── middleware/\n│   └── index.js          # Access token verification\n├── services/\n│   └── index.js          # Cookie utility functions\n├── .env.example\n├── .gitignore\n├── index.js               # Main Express server\n├── package.json\n├── vercel.json\n└── README.md\n```\n\n---\n\n## 📄 License\n\nThis project is for educational purposes. Feel free to fork and use for your own learning or demo needs.\n\n---\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohdajmalraza%2Foauth-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohdajmalraza%2Foauth-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohdajmalraza%2Foauth-server/lists"}