'/usercallback' for OAuth2 runs as HEAD on published Google Addon

Viewed 137

I have a rather simple-sounding issue. I have created a published Google Sheets addon. This addon connects to an external service using OAuth2 with this library.

As part of this library you configure the callback URL to be like below: https://script.google.com/macros/d/[SCRIPT ID]/usercallback

When this runs for the user's login it will always run the callback as the HEAD deployment.

This poses the issue that anything run on this callback request will be configured as the HEAD deployment, meaning most recent version, and it causes issues with triggers. I'm trying to see if I can run this callback as a versioned deployment to fix this issue.

My Callback code:

function authCallback(request) {
  const testService = getOAuthService();
  var authorized = testService.handleCallback(request);
  console.log(authorized)
  if (authorized) {

    setActiveSpreadsheetID();
    setUpDocument();
    addTriggers();
    setUserProperty("isSignedIn","true");
    setUserProperty('syncStatus', "ready")
    getOrgData();
    return HtmlService.createHtmlOutputFromFile('sheetsAddOn/signin-success');
  } else {
    return HtmlService.createHtmlOutputFromFile('sheetsAddOn/signin-failure');
  };
};

Everything works fine, even as head, except the triggers. It also causes the problem that it will call these functions based on the latested (unreleased) version of the function.

0 Answers
Related