google-oauth-cli-generator
v1.0.0
Published
CLI tool to quickly set up Google OAuth authentication for hackathons and projects
Maintainers
Readme
🚀 CipherAI Auth Setup CLI
A powerful CLI tool to quickly set up Google OAuth authentication for hackathons and projects. Generate complete authentication boilerplates in seconds!
✨ Features
- 🔐 Complete Google OAuth Setup - Full authentication flow with Passport.js
- ⚡ Multiple Frontend Frameworks - React, Next.js, or Vanilla JavaScript
- 🚀 Backend Options - Express.js or Fastify
- 💾 Database Support - MongoDB, PostgreSQL, or in-memory storage
- 🎨 Beautiful UI - Pre-styled login components with modern design
- 📦 Zero Configuration - Just run and answer prompts
- 🧪 Test Ready - Includes comprehensive test suites
- 📚 Documentation - Complete setup guides and examples
🚀 Quick Start
Installation
# Install globally
npm install -g @cipherai/auth-setup
# Or use npx (recommended)
npx @cipherai/auth-setup setupUsage
# Initialize new authentication project
cipherai-auth setup
# Or using npx
npx @cipherai/auth-setup setup📋 Prerequisites
Before running the CLI, you'll need:
Google Cloud Console Project
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
OAuth 2.0 Credentials
- Navigate to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Choose "Web Application"
- Add your redirect URI (e.g.,
http://localhost:3000/auth/google/callback)
🎯 What You'll Get
The CLI will ask you a few questions and generate a complete project structure:
📝 Questions Asked
- Google OAuth Client ID - Your Google OAuth client ID
- Google OAuth Client Secret - Your Google OAuth client secret
- Redirect URI - OAuth callback URL (default:
http://localhost:3000/auth/google/callback) - Frontend Framework - React, Next.js, or Vanilla JavaScript
- Backend Framework - Express.js or Fastify
- Database - MongoDB, PostgreSQL, or none (in-memory)
- Project Name - Name for your project folder
📁 Generated Structure
your-project/
├── frontend/ # Frontend application
│ ├── src/
│ │ ├── components/ # Login/Profile components
│ │ ├── App.tsx # Main application
│ │ └── ...
│ ├── package.json
│ └── ...
├── backend/ # Backend API server
│ ├── src/
│ │ ├── routes/ # Authentication routes
│ │ ├── config/ # Passport & database config
│ │ ├── models/ # User models (if database selected)
│ │ └── index.ts # Server entry point
│ ├── package.json
│ └── ...
├── .env.example # Environment variables template
├── .gitignore # Git ignore rules
└── README.md # Project documentation🛠 Supported Tech Stacks
Frontend Options
- React - Modern React with TypeScript, Vite, and styled components
- Next.js - Next.js 14 with App Router and TypeScript
- Vanilla JS - Pure JavaScript with modern ES6+ features
Backend Options
- Express.js - Popular Node.js framework with Passport.js
- Fastify - High-performance alternative to Express
Database Options
- MongoDB - NoSQL database with Mongoose ODM
- PostgreSQL - Relational database with native pg driver
- None - In-memory storage for quick prototypes
🚀 Getting Started (After Generation)
Navigate to your project
cd your-project-nameSet up environment variables
cp .env.example .env # Edit .env with your actual valuesInstall dependencies
# Frontend cd frontend && npm install # Backend cd ../backend && npm installStart development servers
# Terminal 1 - Backend cd backend && npm run dev # Terminal 2 - Frontend cd frontend && npm run devOpen your browser
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
🔧 Environment Variables
Required Variables
# Google OAuth Configuration
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
REDIRECT_URI=http://localhost:3000/auth/google/callback
# Session Configuration
SESSION_SECRET=your-session-secret-change-in-production
# Database Configuration (if using database)
MONGODB_URI=mongodb://localhost:27017/your-app
# OR
DATABASE_URL=postgresql://username:password@localhost:5432/your_app
# Application Configuration
PORT=5000
NODE_ENV=development
FRONTEND_URL=http://localhost:3000📚 API Reference
Authentication Endpoints
GET /api/auth/google- Initiate Google OAuth flowGET /api/auth/google/callback- OAuth callback handlerGET /api/auth/user- Get current authenticated userPOST /api/auth/logout- Logout user
Health Check
GET /api/health- Server health status
🧪 Testing
The generated project includes comprehensive test suites:
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch🚀 Deployment
Frontend Deployment
Vercel (Recommended for Next.js)
npm install -g vercel
vercelNetlify (Great for React/Vanilla)
npm run build
# Upload dist/ folder to NetlifyBackend Deployment
Railway
npm install -g @railway/cli
railway login
railway init
railway upHeroku
heroku create your-app-name
git push heroku mainEnvironment Variables in Production
Remember to set these in your deployment platform:
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETREDIRECT_URI(update to production URL)SESSION_SECRET(generate a secure random string)- Database connection strings
NODE_ENV=production
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
# Clone the repository
git clone https://github.com/cipherai/auth-setup.git
cd auth-setup
# Install dependencies
npm install
# Run in development mode
npm run dev
# Run tests
npm test
# Build for production
npm run build📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🐛 Issues & Support
🙏 Acknowledgments
- Passport.js - Simple, unobtrusive authentication
- Google OAuth 2.0 - Secure authentication
- Inquirer.js - Beautiful command line interfaces
📊 Stats
Made with ❤️ by CipherAI for the developer community
