SB1100
SB1100

Reputation: 101

Unexpected error while getting the method or property getAuthorizationInfo on object ScriptApp

I have an apps script running behind a Google Form and just in the last couple of weeks, I have been getting an error from my code.

The problem code is:

var authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL);

And the error is:

Unexpected error while getting the method or property getAuthorizationInfo on object ScriptApp.

The code is now running under the V8 engine.

Upvotes: 3

Views: 6174

Answers (3)

Alexander Taylor
Alexander Taylor

Reputation: 17642

If you tried fixing the v8 engine oauth scoping issue as mentioned in other answers and that still doesn't work, be sure to pass in valid arguments (especially of the right type) to the method mentioned in the error.

I got an "Exception: Unexpected error while getting the method or property openById on object SpreadsheetApp" error because my trigger handler took some default parameters (including sheet ID) that I overrode for testing, and I hadn't realized that Apps Script actually passes in some parameters (the event object). I ended up calling "SpreadsheetApp.openById" on the event object instead of ID string. And, the error made it sound like it was failing before the argument even got passed in, so it was a pain to track down. Anyway, fwiw, the arguments do matter, and it's not necessarily a scoping issue.

Upvotes: 5

Cooper
Cooper

Reputation: 64072

Someone asked for an example of how to copy the scopes into the manifest file:

"oauthScopes": ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/script.external_request", "https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/script.container.ui", "https://www.googleapis.com/auth/calendar", "https://www.googleapis.com/auth/gmail.send", "https://www.googleapis.com/auth/script.send_mail", "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/presentations", "https://www.googleapis.com/auth/cloud-platform"],

Upvotes: 2

Jescanellas
Jescanellas

Reputation: 2608

For anyone who could face this issue:

As @Cooper mentioned, writing the scopes in the manifest file (View > Show Manifest file) provides a workaround for the issue.

Upvotes: 1

Related Questions