Google Apps Script Deployment Guide
Google Apps Script Deployment Guide
Step 1: Create New Apps Script Project
- Go to https://script.google.com/
- Click “New Project”
- Name it:
QR Attendance Validator
Step 2: Copy the Code
- Delete any default code in the editor
- Copy all code from
attendance-validator.gs - Paste it into the Apps Script editor
- IMPORTANT: Change the
SECRET_KEYon line 11:const SECRET_KEY = 'MySecretKey_' + Math.random(); // Make this unique!Example:
const SECRET_KEY = 'ADA_Stats_2025_xyz789abc';
Step 3: Deploy as Web App
- Click “Deploy” → “New deployment”
- Click gear icon ⚙️ → Select “Web app”
- Fill in:
- Description:
QR Attendance Validator - Execute as:
Me (your-email@gmail.com) - Who has access:
Anyone(no authentication)
- Description:
- Click “Deploy”
- Copy the Web App URL - looks like:
https://script.google.com/macros/s/ABC123...XYZ/exec⚠️ Save this URL - you’ll need it for the next step!
Step 4: Test the Deployment
- In Apps Script editor, click “Run” → Select
testSignature - First time: Authorize the script (click “Review Permissions”)
- Check “View” → “Logs” to see the test output
- You should see something like:
Timestamp: 1731744000000 Signature: a1b2c3d4e5f6g7h8 Token: 1731744000000|a1b2c3d4e5f6g7h8
Step 5: Update Attendance Page
Copy your Apps Script Web App URL and update the attendance page.
I’ll do this for you now…
Step 6: Test End-to-End
- Visit your attendance page:
https://sorujov.net/attendance/math-stat-1/ - QR code should display
- Scan with phone
- Should redirect to Google Form with session time pre-filled
- Wait 6 minutes, scan old QR → Should show “Expired” page
Troubleshooting
“Authorization required”
- Re-deploy with “Execute as: Me” and “Anyone” access
- Make sure you authorized the script
“Invalid signature”
- Make sure
SECRET_KEYmatches in both:- Apps Script (line 11)
- Attendance page JavaScript
“Missing token”
- Check that WORKER_URL in attendance page is correct
- Should be:
https://script.google.com/macros/s/YOUR_ID/exec
Security Notes
✅ Apps Script URL is public - This is intentional and safe
- Token validation prevents unauthorized access
- Only valid tokens (< 5 min old) work
- Signature prevents token tampering
✅ SECRET_KEY must match in both places:
- Apps Script (
attendance-validator.gsline 11) - Attendance page JavaScript
❌ Don’t share your SECRET_KEY publicly
- Keep it secret between your Apps Script and attendance page
- Change it if you suspect it’s been compromised
Advanced: Managing Multiple Classes
To use for multiple classes, you can:
- Option A: Use same Apps Script, different SECRET_KEYs per class
- Option B: Deploy multiple Apps Script projects (one per class)
- Option C: Add class ID to token and validate in Apps Script
For now, one deployment works for all your classes!
