admin管理员组

文章数量:1289636

I've built a Google Workspace Add-on for Google Docs that allows users to highlight specific text when selecting a menu option. The function relies on DocumentApp.getActiveDocument() to modify the currently open document.

Problem: When using the narrow scope (.file), the following issues arise:

DocumentApp.getActiveDocument() is unavailable, preventing access to the current document. The add-on cannot detect the document it was triggered from, meaning the current document is not included in the list of accessible files.

Google suggests using the Drive Picker, but this creates a terrible user experience—forcing users to manually search for the document they are already working on just to proceed.

Why does this matter: The expanded Docs scope () allows seamless functionality, removing these issues. However, it is classified as Sensitive and requires annual verification, adding unnecessary compliance burdens.

Suggested Fix: Google should allow drive.file to include the document from which the menu item was called, or make getActiveDocument() work within the drive.file scope. This would enable add-ons to function without forcing users to pick their own active document manually.

Would anyone have insights on this limitation, or is there an alternative approach to getting the active document without requiring full Docs access?

I've built a Google Workspace Add-on for Google Docs that allows users to highlight specific text when selecting a menu option. The function relies on DocumentApp.getActiveDocument() to modify the currently open document.

Problem: When using the narrow scope (https://www.googleapis/auth/drive.file), the following issues arise:

DocumentApp.getActiveDocument() is unavailable, preventing access to the current document. The add-on cannot detect the document it was triggered from, meaning the current document is not included in the list of accessible files.

Google suggests using the Drive Picker, but this creates a terrible user experience—forcing users to manually search for the document they are already working on just to proceed.

Why does this matter: The expanded Docs scope (https://www.googleapis/auth/documents) allows seamless functionality, removing these issues. However, it is classified as Sensitive and requires annual verification, adding unnecessary compliance burdens.

Suggested Fix: Google should allow drive.file to include the document from which the menu item was called, or make getActiveDocument() work within the drive.file scope. This would enable add-ons to function without forcing users to pick their own active document manually.

Would anyone have insights on this limitation, or is there an alternative approach to getting the active document without requiring full Docs access?

Share Improve this question edited Feb 28 at 2:49 Jats PPG 8101 gold badge1 silver badge10 bronze badges asked Feb 20 at 17:35 Elliott HedmanElliott Hedman 112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The documentation of getActiveDocument() states the scopes needed for it to work and other options that can be used with it, which means that there's no alternative approach to getting the active document without requiring full Docs access since https://www.googleapis/auth/documents is a sensitive scope.

As per Sensitive scope verification:

If your app requests scopes categorized as sensitive or restricted, you probably need to complete the verification process unless your app's use qualifies for an exception.

If the Google Workspace Add-on for Google Docs is used in any of the following, check to see if it can be exempted for verification:

  • Personal use
  • Projects used in Development, Testing, or Staging tiers
  • Service-owned data only
  • Internal use only
  • Domain-wide installation

If not, and you would like to continue with your Suggested Fix, I recommend that you submit a feature request, as that's the best way to tell Google about these kinds of things.

REFERENCE

  • Exceptions to verification requirements

本文标签: google drive apiGetting activeDocument with drivefile scope in an addonStack Overflow