# 🚀 Dropbox Setup - Quick Reference Card

## ⚡ Quick Setup (5 Minutes)

### 1️⃣ Create App (2 min)
```
https://www.dropbox.com/developers/apps
→ Create app
→ Scoped access + Full Dropbox
→ Name: CSSAwards-FileStorage
```

### 2️⃣ Set Permissions (1 min)
```
Permissions tab → Enable:
✅ files.content.write
✅ files.content.read
✅ sharing.write
✅ sharing.read
→ Submit
```

### 3️⃣ Get App Key & Secret (30 sec)
```
Settings tab:
📋 Copy App key
📋 Copy App secret (click Show)
```

### 4️⃣ Add Redirect URI (30 sec)
```
Settings tab → OAuth 2 → Redirect URIs:
Add: http://localhost
```

### 5️⃣ Get Authorization Code (1 min)
```
Open in browser (replace YOUR_APP_KEY):
https://www.dropbox.com/oauth2/authorize?client_id=sie2iy5wvassus9&response_type=code&token_access_type=offline

→ Click Allow
→ Copy code from URL (after code=)
```

### 6️⃣ Get Refresh Token (30 sec)
```bash
# Edit Backend/get-dropbox-tokens.js
# Replace YOUR_APP_KEY, YOUR_APP_SECRET, YOUR_AUTHORIZATION_CODE
node get-dropbox-tokens.js
# Copy the REFRESH TOKEN from output
```

### 7️⃣ Update .env File (30 sec)
```env
DROPBOX_APP_KEY=your_app_key
DROPBOX_APP_SECRET=your_app_secret
DROPBOX_REFRESH_TOKEN=your_refresh_token
```

### 8️⃣ Test & Done! (30 sec)
```bash
npm start
node test-dropbox-connection.js
# Should see: ✅ All tests passed!
```

---

## 📋 What You Need

| Item | Where to Get | Example |
|------|--------------|---------|
| **App Key** | Settings tab | `abc123xyz456` |
| **App Secret** | Settings tab (click Show) | `xyz789abc123` |
| **Refresh Token** | Run get-dropbox-tokens.js | `def456ghi789...` |

---

## 🔧 Common Issues

### "Invalid authorization code"
→ Code already used or expired  
→ **Fix**: Generate new code (Step 5)

### "Token refresh failed"
→ Wrong credentials in .env  
→ **Fix**: Double-check all 3 values

### "Missing required scopes"
→ Permissions not enabled  
→ **Fix**: Go to Permissions tab (Step 2)

---

## 📚 Full Documentation

- **Detailed Guide**: `DROPBOX_CREDENTIALS_SETUP.md`
- **Integration Guide**: `DROPBOX_INTEGRATION_GUIDE.md`
- **Setup Summary**: `DROPBOX_SETUP_SUMMARY.md`

---

## ✅ Success Checklist

- [ ] App created on Dropbox
- [ ] Permissions enabled (4 permissions)
- [ ] App Key copied
- [ ] App Secret copied
- [ ] Redirect URI added (http://localhost)
- [ ] Authorization code obtained
- [ ] Refresh token generated
- [ ] All 3 values in .env file
- [ ] Server restarted
- [ ] Test passed

---

## 🎯 Final .env File Should Look Like:

```env
# Dropbox OAuth2 Configuration
DROPBOX_APP_KEY=abc123xyz456789
DROPBOX_APP_SECRET=xyz789abc123456
DROPBOX_REFRESH_TOKEN=def456ghi789jkl012mno345pqr678stu901vwx234
```

---

## 🆘 Need Help?

1. Read: `DROPBOX_CREDENTIALS_SETUP.md` (step-by-step guide)
2. Check: Server logs for error messages
3. Verify: All values in .env are correct
4. Test: Run `node get-dropbox-tokens.js`

---

**Time to Complete**: ~5 minutes  
**Difficulty**: Easy  
**Token Expiry**: Never (refresh token doesn't expire!)

---

Last Updated: November 14, 2025
