Google Sheets Add-on error: authorisation is required to perform that action

I have an add-on that worked for years inside my domain/company until Google decided to change stuff. I republished it and now I can run it but nobody else in the company can. The error they receive is:

"Authorisation is required to perform that action".

I cannot pinpoint exactly where the error is because the GCP Log only tells me the function not the line, but it seems most of the times the error appears when showing a sidebar.

I do not use any kind of API, simply GAS but "just in case " I added in OAuth consent screen these scopes: .../auth/script.container.ui and .../auth/spreadsheets.

In Google Workspace Marketplace SDK OAuth Scopes I've just left the default.

Also I tried adding in appscript.json this (at top level):

  "oauthScopes": [
    "https://www.googleapis.com/auth/script.container.ui",
    "https://www.googleapis.com/auth/script.external_request",
    "https://www.googleapis.com/auth/script.scriptapp",
    "https://www.googleapis.com/auth/spreadsheets",
    "https://www.googleapis.com/auth/userinfo.email"
  ]

What else can I try ?

Update: as requested in comments here's the offending code:

// clientside
google.script.run.
withSuccessHandler()
.withFailureHandler(failureHandler)  // failureHandler gets called
.aServerFunc() 

//serverside 
function aServerFunc(){
  Logger.log('REACHED') // NO REACHED APPEARS IN CLOUD LOGS !
  var docProp = PropertiesService.getDocumentProperties();  
  return docProp.getProperty(key)
}

So I guess the problem is nobody else but me can run google.script.run in an add-on !

Update 2: I've removed the PropertiesService calls so it's just a blank function on the server. So it's clear that nobody but me can run google.scripts.run.

Update 3: As required in the comments here's the procedures I did to publish the add-on: I created a google cloud project, then configured the OAuth consentscreen (with the same scopes as appsscript.json - see above list), then in Google Workspace Marketplace SDK I've set the script ID and deployment number and the same scopes and published.

Upvotes: 0

Views: 619

Answers (1)

It turns out the add-on was just fine !

It's just this 4 years old bug that Google refuses to fix If the user is logged in with multiple accounts the default one will be used.

If the default account is non-domain and the add-on is restricted to a domain the add-on will fail to authorise.

Upvotes: 2

Related Questions