Skip to content
Google Apps Script · error message

Apps Script: You do not have permission to call UrlFetchApp.fetch

ConfigurationAuthorization and permissions

Last verified

The exact message
Exception: You do not have permission to call UrlFetchApp.fetch. Required permissions: https://www.googleapis.com/auth/script.external_request

What it means

The running script does not hold the script.external_request OAuth scope, which UrlFetchApp needs to contact external URLs. The message names the missing scope directly.

There are two common situations. First, the function runs in a context that cannot use authorized services at all: Google documents that simple triggers such as onEdit and onOpen can't access services that require authorization. Second, the project's appsscript.json sets oauthScopes explicitly; Google's reference says you must then add this scope manually, because automatic scope detection is turned off.

The same pattern produces You do not have permission to call messages for other services, such as MailApp.sendEmail or SpreadsheetApp.openById.

What it looks like

// appsscript.json
{
  "oauthScopes": [
    "https://www.googleapis.com/auth/spreadsheets.currentonly",
    "https://www.googleapis.com/auth/script.external_request"
  ]
}

Why it happens

  • The fetch is inside a simple trigger (a function literally named onEdit or onOpen).
  • The manifest lists oauthScopes explicitly and does not include script.external_request.
  • The code was changed to add UrlFetchApp after the user last authorized the script.
  • A custom function or add-on context that does not have the scope granted.

How to fix it

  1. If the call is in onEdit or onOpen, rename the function (for example handleEdit) and create an installable On edit or On open trigger for it from the Triggers page.
  2. If appsscript.json has an oauthScopes array, add "https://www.googleapis.com/auth/script.external_request" to it.
  3. Run any function manually from the editor to bring up the authorization dialog and accept it.
  4. Re-test by triggering the event (editing a cell, opening the file) rather than running the function from the editor.

How to stop it recurring

Keep simple triggers for lightweight, local work only; anything that sends mail, opens other files or calls the network belongs in an installable trigger. If you declare scopes manually, review the list whenever you add a new service call.

Official documentation: developers.google.com/apps-script/reference/url-fetch/url-fetch-app. See all Apps Script error messages or the Apps Script limits and quotas.

Related errors

Definitions

Quick answers

What does "You do not have permission to call UrlFetchApp.fetch" mean in Apps Script?

The running script does not hold the script.external_request OAuth scope, which UrlFetchApp needs to contact external URLs. The message names the missing scope directly. There are two common situations. First, the function runs in a context that cannot use authorized services at all: Google documents that simple triggers such as onEdit and onOpen can't access services that require authorization.

How do I fix "You do not have permission to call UrlFetchApp.fetch"?

1. If the call is in onEdit or onOpen, rename the function (for example handleEdit) and create an installable On edit or On open trigger for it from the Triggers page. 2. If appsscript.json has an oauthScopes array, add "https://www.googleapis.com/auth/script.external_request" to it. 3. Run any function manually from the editor to bring up the authorization dialog and accept it. 4. Re-test by triggering the event (editing a cell, opening the file) rather than running the function from the editor.

Run the job somewhere with its own limits

If a script keeps hitting its host's quotas, an Autonoly workflow can run the same steps on a schedule in an isolated cloud container, and the AI agent has a terminal with Python for steps that need code. Autonoly has limits of its own, priced in credits.

Also see Agent terminal & SSH.