Chris
Chris

Reputation: 391

How to get permission to run a google app Script from a Chrome Extension?

I'm trying to capture selected text in a chrome extension and put it in a Google Doc, however whenever I try to run the script with the packaged extension I get the following errors.

The given range does not belong to the current selection's document.

Blocked script execution in 'https://docs.google.com/document/d/1E23-KSMXgymTVpYVtimQHw26yrqAVYlNHUb59zcPleU/edit' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.

Any info on how to fix these issues would be amazing.

Upvotes: 1

Views: 929

Answers (1)

Teyam
Teyam

Reputation: 8122

As discussed in Authorization for Google Services,

Scripts do not request authorization if they use only services that cannot access user data or if you access the script as a web app that runs under the script owner's user identity.

The user identity that a script runs with — and thus the data it can access — varies based on the scenario in which the script is run, as shown in the table given in Permissions and types of scripts.

For additional information, please check solution given in this SO posts - Running Apps Script from Chrome extension requires authorization and Can I execute Google Apps Script code from a Chrome extension?.

Lastly, to help you troubleshoot the encountered issue, you may try to

Look at the "Execution Transcript" under "View" in the Script Editor, immediately after receiving the error.

It should show the file & line number where the exception occurred.

as given in this SO post - How do I find the “operation's” location within the code? 'This operation is not supported from a callback function.'?

Upvotes: 1

Related Questions