AI Security¶
Key handling¶
- Store provider keys in script properties.
- Do not hardcode API keys in source files.
- Do not commit local auth files (
.clasp.json,.clasprc.json,client_secret.json,creds.json).
Auth precedence¶
ASTX.AI resolves auth in this order:
- per-call
request.auth.* - runtime config (
ASTX.AI.configure(...)) - script properties
- throw
AstAiAuthError
This makes override behavior explicit and deterministic.
Vertex Gemini auth¶
vertex_gemini supports three auth modes:
oauth: use bearer token fromrequest.auth.oauthToken/request.auth.accessTokenorScriptApp.getOAuthToken().service_account: userequest.auth.serviceAccountJsonor script propertyVERTEX_SERVICE_ACCOUNT_JSON.auto(default): prefer service-account JSON when present, otherwise fallback to OAuth.
Optional script properties:
VERTEX_SERVICE_ACCOUNT_JSONVERTEX_AUTH_MODE(oauth|service_account|auto)
When using service-account auth, token_uri from the JSON is allowlisted to Google token endpoints:
https://oauth2.googleapis.com/tokenhttps://www.googleapis.com/oauth2/v4/token
Required scope in appsscript.json:
https://www.googleapis.com/auth/cloud-platform
Service-account token exchange is cached with a safe expiry buffer to reduce repeated JWT exchange calls.
Provider controls¶
- Use
providerOptionsonly for known provider-native fields. - Use
options.includeRaw=trueonly for debugging and avoid logging sensitive payloads. - Validate and sanitize tool handler outputs before using them in downstream operations.
Tool execution safety¶
- Keep handlers side-effect-free unless side effects are intentional.
- Use explicit input schemas for every tool.
- Keep
maxToolRoundsbounded (default3) to prevent runaway loops.
Operational guidance¶
- Restrict script/editor access to least privilege.
- Rotate keys on a regular schedule.
- Prefer dedicated keys per environment (dev/staging/prod).
- Log only minimal metadata in production (provider, model, token counts, status).