validateDeploymentID checks that the value looks like an Apps Script deployment ID and produces a hint when it looks like a common copy-paste mistake. The exact format Google uses isn't documented, but every observed ID starts with "AKfycb" and is 50+ characters long.
(id string)
| 231 | // mistake. The exact format Google uses isn't documented, but every observed |
| 232 | // ID starts with "AKfycb" and is 50+ characters long. |
| 233 | func validateDeploymentID(id string) error { |
| 234 | if id == "" { |
| 235 | return errors.New("empty value in script_keys") |
| 236 | } |
| 237 | if id == "REPLACE_WITH_DEPLOYMENT_ID" || id == "OPTIONAL_SECOND_DEPLOYMENT_ID" { |
| 238 | return errors.New("script_keys still contains the placeholder text from client_config.example.json — replace it with your real Deployment ID (see README Step 5)") |
| 239 | } |
| 240 | if strings.Contains(id, "/edit") || strings.Contains(id, "script.google.com/d/") { |
| 241 | return errors.New("this looks like the Apps Script *editor* URL, not a Deployment ID. Open the deployment from Deploy → Manage deployments, click the deployed Web App URL, and copy the long string between /s/ and /exec") |
| 242 | } |
| 243 | if strings.ContainsAny(id, " \t\n\r") { |
| 244 | return errors.New("script_keys value contains whitespace — paste the Deployment ID without spaces or line breaks") |
| 245 | } |
| 246 | if !strings.HasPrefix(id, "AKfycb") { |
| 247 | return errors.New("deployment IDs start with 'AKfycb' — you may have pasted the script ID (from the editor) instead of the Deployment ID. After deploying, open Deploy → Manage deployments and copy the ID from the Web App URL") |
| 248 | } |
| 249 | if len(id) < 50 { |
| 250 | return fmt.Errorf("deployment ID looks too short (%d chars; expected ~70) — it may be truncated, re-copy from Deploy → Manage deployments", len(id)) |
| 251 | } |
| 252 | return nil |
| 253 | } |
| 254 | |
| 255 | // parseSNIHosts parses the "sni" JSON field, which may be either a single |
| 256 | // string ("www.google.com") or an array (["www.google.com", "mail.google.com"]). |