- Add detailed step-by-step guides for Microsoft Azure and Google Cloud OAuth app registration - Specify required API permissions and redirect URIs for both providers - Include security note emphasizing client secrets stored only on backend - Update environment variable configuration for frontend and backend with examples - Enhance UI badges to conditionally display connection direction and status - Revise Azure and Google setup instructions in the app interface for clarity and completeness - Improve alert sections to clearly separate frontend and backend environment file instructions
182 lines
6.1 KiB
Markdown
182 lines
6.1 KiB
Markdown
# OneDrive ↔ Google Drive Streamer
|
||
|
||
A secure, high-performance application to stream files bidirectionally between Microsoft OneDrive and Google Drive.
|
||
Now powered by a **Node.js Express backend** for reliable server-side streaming and token management.
|
||
|
||
## Features
|
||
|
||
- <20> **Bidirectional Transfers**: Move files from OneDrive to Google Drive AND Google Drive to OneDrive.
|
||
- 🚀 **Server-Side Streaming**: Files are piped directly between cloud providers on the server, ensuring faster and more reliable transfers for large files.
|
||
- <20> **Secure OAuth 2.0**: Implements robust Authorization Code Flow via the backend.
|
||
- 📊 **Real-time Progress**: Track transfer status with live progress updates.
|
||
- 📁 **File Management**: Browse and select files from your connected cloud storage.
|
||
|
||
## Prerequisites
|
||
|
||
- Node.js (v18 or higher)
|
||
- npm or yarn
|
||
|
||
## Setup
|
||
|
||
### 1. Clone the repository
|
||
```bash
|
||
git clone <repository-url>
|
||
cd <repository-directory>
|
||
```
|
||
|
||
### 2. Install Dependencies
|
||
You need to install dependencies for both the frontend and the backend.
|
||
|
||
**Frontend:**
|
||
```bash
|
||
npm install
|
||
```
|
||
|
||
**Backend:**
|
||
```bash
|
||
cd server
|
||
npm install
|
||
cd ..
|
||
```
|
||
|
||
### 3. Configure OAuth Applications
|
||
|
||
#### Step A: Microsoft Azure (OneDrive)
|
||
|
||
1. Go to **[Azure Portal](https://portal.azure.com)** → **Azure Active Directory** → **App registrations**
|
||
2. Click **"New registration"**
|
||
3. Fill in:
|
||
- **Name**: `CloudStream Transfer` (or any name)
|
||
- **Supported account types**: "Accounts in any organizational directory and personal Microsoft accounts"
|
||
- **Redirect URI**: Select "Single-page application (SPA)" and enter:
|
||
- Development: `http://localhost:5173/auth/callback`
|
||
- Production: `https://yourdomain.com/auth/callback`
|
||
4. Click **Register**
|
||
5. Copy the **Application (client) ID** → This is your `VITE_MS_CLIENT_ID`
|
||
6. Go to **Certificates & secrets** → **New client secret**
|
||
- Add a description and expiry
|
||
- Copy the **Value** immediately (shown only once) → This is your `MS_CLIENT_SECRET`
|
||
7. Go to **API permissions** → **Add a permission** → **Microsoft Graph** → **Delegated permissions**
|
||
- Add: `Files.Read`, `Files.Read.All`, `Files.ReadWrite`, `Files.ReadWrite.All`, `User.Read`
|
||
- Click **Grant admin consent** (if you're an admin)
|
||
|
||
#### Step B: Google Cloud (Google Drive)
|
||
|
||
1. Go to **[Google Cloud Console](https://console.cloud.google.com)**
|
||
2. Create a new project or select existing one
|
||
3. Go to **APIs & Services** → **Enabled APIs & Services**
|
||
- Click **+ ENABLE APIS AND SERVICES**
|
||
- Search for **"Google Drive API"** and **Enable** it
|
||
4. Go to **APIs & Services** → **Credentials**
|
||
5. Click **+ CREATE CREDENTIALS** → **OAuth client ID**
|
||
- If prompted, configure the **OAuth consent screen** first:
|
||
- User Type: External
|
||
- App name, support email, developer email (required fields)
|
||
- Scopes: Add `https://www.googleapis.com/auth/drive`
|
||
6. Back to Credentials → **OAuth client ID**:
|
||
- Application type: **Web application**
|
||
- Name: `CloudStream Transfer`
|
||
- Authorized redirect URIs:
|
||
- `http://localhost:5173/auth/callback` (development)
|
||
- `https://yourdomain.com/auth/callback` (production)
|
||
7. Click **Create**
|
||
8. Copy **Client ID** → This is your `VITE_GOOGLE_CLIENT_ID`
|
||
9. Copy **Client Secret** → This is your `GOOGLE_CLIENT_SECRET`
|
||
|
||
#### Step C: Create Environment Files
|
||
|
||
**Frontend (`.env` in root directory):**
|
||
```env
|
||
VITE_MS_CLIENT_ID=your_microsoft_client_id
|
||
VITE_GOOGLE_CLIENT_ID=your_google_client_id
|
||
```
|
||
|
||
**Backend (`server/.env`):**
|
||
```env
|
||
PORT=9173
|
||
|
||
# Microsoft (same Client ID as frontend + secret)
|
||
VITE_MS_CLIENT_ID=your_microsoft_client_id
|
||
MS_CLIENT_SECRET=your_microsoft_client_secret
|
||
|
||
# Google (same Client ID as frontend + secret)
|
||
VITE_GOOGLE_CLIENT_ID=your_google_client_id
|
||
GOOGLE_CLIENT_SECRET=your_google_client_secret
|
||
|
||
# Must match your OAuth app redirect URI
|
||
REDIRECT_URI=http://localhost:5173/auth/callback
|
||
```
|
||
|
||
> **🔐 Security Note**: Client IDs are public (like your app's name). Client Secrets are private and ONLY stored on the backend - never exposed to browsers. Your files are safe!
|
||
|
||
### 4. Run the Application
|
||
|
||
You need to run both the backend server and the frontend client.
|
||
|
||
**Start Backend (Terminal 1):**
|
||
```bash
|
||
cd server
|
||
npm run dev
|
||
```
|
||
*Server runs on http://localhost:3001*
|
||
|
||
**Start Frontend (Terminal 2):**
|
||
```bash
|
||
npm run dev
|
||
```
|
||
*Frontend runs on http://localhost:5173*
|
||
|
||
## Project Structure
|
||
|
||
- **`/server`**: Node.js Express Backend
|
||
- `src/routes`: API endpoints (`/auth`, `/transfer`)
|
||
- `src/services`: Cloud provider integration (`onedrive.ts`, `googledrive.ts`)
|
||
- **`/src`**: React Frontend
|
||
- `components`: UI components (Cards, Progress, Alerts)
|
||
- `lib/api.ts`: API client for communicating with the backend
|
||
- `App.tsx`: Main application logic and state management
|
||
|
||
## Technologies
|
||
|
||
- **Frontend**: React, TypeScript, Vite, Tailwind CSS, Lucide Icons, Shadcn UI
|
||
- **Backend**: Node.js, Express, TypeScript, Axios, Microsoft Graph Client, Google APIs
|
||
|
||
## Docker & Coolify Deployment
|
||
|
||
### Local Docker
|
||
```bash
|
||
# Build and run with Docker Compose
|
||
docker-compose up --build
|
||
|
||
# Access at http://localhost
|
||
```
|
||
|
||
### Coolify Deployment
|
||
|
||
#### From Public Repository
|
||
1. In Coolify, go to **Projects → New → From Git Repository**
|
||
2. Select **GitHub/GitLab/Bitbucket** and enter the repo URL
|
||
3. Set **Build Pack** to `Docker Compose`
|
||
4. Configure environment variables in Coolify's UI
|
||
|
||
#### From Private Repository
|
||
1. In Coolify, go to **Settings → Private Keys** and add your SSH key
|
||
2. Create new project with **Private Repository** option
|
||
3. Use SSH URL: `git@github.com:username/repo.git`
|
||
4. Configure environment variables in Coolify's UI
|
||
|
||
#### Required Environment Variables (Coolify UI)
|
||
| Variable | Description |
|
||
|----------|-------------|
|
||
| `VITE_MS_CLIENT_ID` | Microsoft/Azure OAuth Client ID |
|
||
| `MS_CLIENT_SECRET` | Microsoft/Azure OAuth Secret |
|
||
| `VITE_GOOGLE_CLIENT_ID` | Google OAuth Client ID |
|
||
| `GOOGLE_CLIENT_SECRET` | Google OAuth Secret |
|
||
| `REDIRECT_URI` | `https://yourdomain.com/auth/callback` |
|
||
|
||
> **Important**: Update your OAuth app redirect URIs in Azure Portal and Google Cloud Console to match your Coolify domain.
|
||
|
||
## License
|
||
|
||
ISC
|