google-apps-scriptgoogle-appsgmail-addonsgoogle-apps-script-addon

Problem with CardService.newAuthorizationException()


I have two Gmail Add-ons with the same code (DEV and PROD versions). And in my code I have standard accessProtectedResource function (from Add-ons documentation):

  function accessProtectedResource(url, data) {
  var service = getOAuthService();
  var maybeAuthorized = service.hasAccess();

  if (maybeAuthorized) {
    ...
  }

  if (!maybeAuthorized) {
    CardService.newAuthorizationException()
    .setAuthorizationUrl(service.getAuthorizationUrl())
    .setResourceDisplayName("Timelines")
    .throwException();
  }
}

The problem is that if user not authorized - in PROD version this function build AuthorizationCard correctly:

enter image description here

But in DEV, with the same code, the same function is crashing the add-on: enter image description here enter image description here

Any ideas?


Solution

  • This is a bug!

    This is a bug that has been reported before on Google Issue Tracker:


    Class AuthorizationException issue on V8


    You can hit the ☆ next to the issue number in the top left on this page as it lets Google know more people are encountering this and so it is more likely to be seen to faster.