diff --git a/README.md b/README.md index ed434f2..6eb242b 100644 --- a/README.md +++ b/README.md @@ -39,31 +39,75 @@ npm install cd .. ``` -### 3. Configure Environment Variables +### 3. Configure OAuth Applications -**Frontend (`.env`):** -Create a `.env` file in the root directory: +#### 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`):** -Create a `.env` file in the `server` directory: ```env -PORT=3001 -# Microsoft Graph Credentials +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 Drive Credentials +# 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 ``` -> **Note:** You must register applications in both Azure Portal and Google Cloud Console. -> Ensure the Redirect URI is set to `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 diff --git a/src/App.tsx b/src/App.tsx index 78f35f9..f1ebb64 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -404,21 +404,43 @@ function App() {
- - {authState.onedrive ? '✓ OneDrive Connected' : 'OneDrive'} - - - - {authState.googledrive ? '✓ Google Drive Connected' : 'Google Drive'} - + {direction === 'onedrive-to-google' ? ( + <> + + {authState.onedrive ? '✓ OneDrive Connected' : 'OneDrive'} + + + + {authState.googledrive ? '✓ Google Drive Connected' : 'Google Drive'} + + + ) : ( + <> + + {authState.googledrive ? '✓ Google Drive Connected' : 'Google Drive'} + + + + {authState.onedrive ? '✓ OneDrive Connected' : 'OneDrive'} + + + )}
@@ -470,47 +492,84 @@ function App() {

- Microsoft OneDrive + Step 1: Microsoft Azure

    -
  1. Go to Azure Portal
  2. -
  3. Navigate to Azure AD > App registrations
  4. -
  5. Click "New registration"
  6. -
  7. Set redirect URI: {window.location.origin}/auth/callback
  8. -
  9. Add API permissions: Files.Read, Files.Read.All
  10. -
  11. Copy Client ID to environment variable
  12. +
  13. Go to Azure Portal → Azure AD → App registrations
  14. +
  15. Click "New registration"
  16. +
  17. Set account type: "Personal Microsoft accounts"
  18. +
  19. Add Redirect URI (SPA): {window.location.origin}/auth/callback
  20. +
  21. Copy Application (client) ID
  22. +
  23. Go to Certificates & secrets → New client secret
  24. +
  25. Copy the secret Value immediately
  26. +
  27. Go to API permissions → Add: Files.Read.All, Files.ReadWrite.All, User.Read

- Google Drive + Step 2: Google Cloud

  1. Go to Google Cloud Console
  2. Create or select a project
  3. -
  4. Enable Google Drive API
  5. -
  6. Create OAuth 2.0 credentials
  7. -
  8. Set redirect URI: {window.location.origin}/auth/callback
  9. -
  10. Copy Client ID to environment variable
  11. +
  12. Enable Google Drive API
  13. +
  14. Configure OAuth consent screen (External)
  15. +
  16. Create OAuth 2.0 credentials (Web app)
  17. +
  18. Add Redirect URI: {window.location.origin}/auth/callback
  19. +
  20. Copy Client ID and Client Secret
  21. +
  22. Add scope: https://www.googleapis.com/auth/drive
- -
-
- + + {/* Environment Files Section */} +
+ +
+
+ +
+
+
Step 3: Frontend .env
+ +

Create .env in root:

+
+ VITE_MS_CLIENT_ID=your_ms_id + VITE_GOOGLE_CLIENT_ID=your_google_id +
+
+
-
-
💡 Environment Setup
- -

Create a .env file with:

-
- VITE_MS_CLIENT_ID=your_microsoft_id - VITE_GOOGLE_CLIENT_ID=your_google_id -
-
+ + +
+
+ +
+
+
Step 4: Backend server/.env
+ +
+ PORT=9173 + VITE_MS_CLIENT_ID=your_ms_id + MS_CLIENT_SECRET=your_ms_secret + VITE_GOOGLE_CLIENT_ID=your_google_id + GOOGLE_CLIENT_SECRET=your_google_secret + REDIRECT_URI={window.location.origin}/auth/callback +
+
+
+
+
+ + +
+ + + 🔐 Security: Client Secrets are stored ONLY on the backend server - never exposed to browsers. Your files are safe! +