diff --git a/.changeset/angry-apes-sing.md b/.changeset/angry-apes-sing.md new file mode 100644 index 0000000..cad8ecd --- /dev/null +++ b/.changeset/angry-apes-sing.md @@ -0,0 +1,7 @@ +--- +"google-workspace-developer-tools": patch +--- + +Added missing currentonly scopes for Apps Script (Docs, Sheets, Slides, Forms). The currentonly scope is only available within Apps Script Services. This does not include Apps Script Advanced Services or direct calls to Google Workspace APIs. + +For more information, see [Editor scopes](https://developers.google.com/workspace/add-ons/concepts/workspace-scopes#editor-scopes) and [Apps Script currentonly scopes](https://justin.poehnelt.com/posts/apps-script-currentonly-scopes/). diff --git a/packages/vscode-extension/src/scopes.ts b/packages/vscode-extension/src/scopes.ts index 597e522..83779a6 100644 --- a/packages/vscode-extension/src/scopes.ts +++ b/packages/vscode-extension/src/scopes.ts @@ -66,12 +66,33 @@ for (const { title, version, documentationLink, scopes } of GOOGLE_APIS || []) { export const SCRIPT_EXTERNAL_REQUEST_SCOPE = "https://www.googleapis.com/auth/script.external_request"; - SCOPES.set(SCRIPT_EXTERNAL_REQUEST_SCOPE, { description: "Connect to an external service", apis: [], }); +/** + * Scopes that are only available for the current document. + * + * @see https://developers.google.com/workspace/add-ons/concepts/workspace-scopes#editor-scopes + * @see https://justin.poehnelt.com/posts/apps-script-currentonly-scopes/ + */ +export const CURRENT_ONLY_SCOPES = [ + "https://www.googleapis.com/auth/documents.currentonly", + "https://www.googleapis.com/auth/forms.currentonly", + "https://www.googleapis.com/auth/presentations.currentonly", + "https://www.googleapis.com/auth/spreadsheets.currentonly", +]; + +for (const scope of CURRENT_ONLY_SCOPES) { + SCOPES.set(scope, { + description: + "Access the current document, sheet, presentation, or form. The `currentonly` scope is only available within Apps Script Services. This does not include Apps Script Advanced Services or direct calls to Google Workspace APIs.", + classification: ScopeClassification.NON_SENSITIVE, + apis: [], + }); +} + const RESTRICTED_SCOPES = [ "https://www.googleapis.com/auth/chat.admin.delete", "https://www.googleapis.com/auth/chat.app.delete",