Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/angry-apes-sing.md
Original file line number Diff line number Diff line change
@@ -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/).
23 changes: 22 additions & 1 deletion packages/vscode-extension/src/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
});
}
Comment on lines +80 to +94

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current implementation uses a generic description for all currentonly scopes. This can be misleading for users, as it suggests that each scope grants access to documents, sheets, presentations, and forms, rather than just the specific type associated with the scope. For example, the description for https://www.googleapis.com/auth/documents.currentonly should clearly state it only accesses the current document. This improves clarity and ensures users understand the permissions they are granting.

const CURRENT_ONLY_SCOPES_DATA = {
	"https://www.googleapis.com/auth/documents.currentonly": "document",
	"https://www.googleapis.com/auth/forms.currentonly": "form",
	"https://www.googleapis.com/auth/presentations.currentonly": "presentation",
	"https://www.googleapis.com/auth/spreadsheets.currentonly": "sheet",
};

export const CURRENT_ONLY_SCOPES = Object.keys(CURRENT_ONLY_SCOPES_DATA);

for (const [scope, entity] of Object.entries(CURRENT_ONLY_SCOPES_DATA)) {
	SCOPES.set(scope, {
		description:
			`Access the current ${entity}. 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",
Expand Down