google-apps-scriptweb-applicationschrome-web-store

Missing publish to Chrome Web Store option for web application


I'm trying to make an inbox-listener element to automatically pull message content with a specific subject line into a Google Spreadsheet for reporting. I'm hoping this GitHub Project will do the trick, and I've made the Google Apps Script project that should handle it. Part of the process is to verify the project ownership by publishing it as draft on the Chrome web store. According to Google's documentation, that should be under the publish function, but I don't see it there, or anywhere in the script editor. Could anyone tell me what I'm doing wrong, or if this feature is disabled?

Here is what the menu looks like in my IDE.

Cannot Find Publish to Webstore Option

Adapted from a OP's comment to the accepted answer

 

The script is definitely not contained in a Google Doc or Spreadsheet, but it is in a workspace tied to a Google Site. Interestingly, I've tried following the link in the KENdi's answer to edit Apps Scripts under my work account, and I'm told I don't have >permission to generate app scripts on that level. I'll send an email to my Admin to see if I can elevate privileges so I can publish through this channel.


GAS Code

main.gs

<meta name="google-site-verification" content="eA0WbBgImGB_wcsnSADjvwnCBaNyrSifyyxuNhHSXf8" />
var PROJECTID = 'api-project-...';
var WEBHOOK_URL = 'My custom project URL'

function doPost(e){
  var postBody = JSON.parse(e.postData.getDataAsString());
  var messageData = Utilities.newBlob(Utilities.base64Decode(postBody.message.data)).getDataAsString();
  var ss = SpreadsheetApp.openById('...').getSheetByName("Log");
  ss.appendRow([new Date(), messageData, JSON.stringify(postBody,undefined,2)])
  return 200;
}

function setupPubSub(){
  var newTopic = CreateTopic("mailTrigger");
  newTopic.setIamPolicy(addGmailPolicy());
  Logger.log(newTopic.getName());
  var newSub = CreateSubscription("mailTrigger",newTopic.getName(),WEBHOOK_URL);
}

function disEnrollEmail(email){
  var email = email || "me";
  var res = UrlFetchApp.fetch("https://www.googleapis.com/gmail/v1/users/"+email+"/stop",{method:"POST",headers:{authorization:"Bearer "+ScriptApp.getOAuthToken()}});
  Logger.log(res.getContentText());
}

function enrollEmail(email){
  var email = email || "me";
  PubSubApp.setTokenService(getTokenService())
  var topicName = PubSubApp.PublishingApp(PROJECTID).getTopicName("mailTrigger")
  Logger.log(watchEmail(topicName,{labelIds:["INBOX"], email:email}));
}

helper.gs

function addGmailPolicy(Policy){
  return PubSubApp.policyBuilder()
  [(Policy)?"editPolicy":"newPolicy"](Policy)
  .addPublisher("SERVICEACCOUNT", 'gmail-api-push@system.gserviceaccount.com')
  .getPolicy();
}

function addDomainSubs(Domain,Policy){
  return PubSubApp.policyBuilder()
  [(Policy)?"editPolicy":"newPolicy"](Policy)
  .addPublisher("DOMAIN", Domain)
  .getPolicy();
}

function getSubscriptionPolicy(){
  return PubSubApp.policyBuilder()
  .newPolicy()
  .addSubscriber("DOMAIN","ccsknights.org")
}


function watchEmail(fullTopicName,watchOptions){
  var options = {email:"me",token:ScriptApp.getOAuthToken(),labelIds:[]};

  for(var option in watchOptions){
    if(option in options){
      options[option] = watchOptions[option];
    }
  }
   Logger.log(options);
  var url = "https://www.googleapis.com/gmail/v1/users/"+options.email+"/watch"

  var payload = {
    topicName: fullTopicName,
    labelIds: options.labelIds
  }

  var params = {
    method:"POST",
    contentType: "application/json",
    payload: JSON.stringify(payload),
    headers:{Authorization: "Bearer "+ options.token
    },
    muteHttpExceptions:true
  }

   var results = UrlFetchApp.fetch(url, params);

  if(results.getResponseCode() != 200){
     throw new Error(results.getContentText())
  }else{
    return JSON.parse(results.getContentText());
  }

 }

function CreateTopic(topicName) {
  var topic;
  PubSubApp.setTokenService(getTokenService());
  var pubservice = PubSubApp.PublishingApp(PROJECTID);
  try{topic = pubservice.newTopic(topicName)}
  catch(e){topic = pubservice.getTopic(topicName);}
  return topic;  
}

function CreateSubscription(subscriptionName,topicName,webhookUrl){
  var sub;
  PubSubApp.setTokenService(getTokenService());
  var subService = PubSubApp.SubscriptionApp(PROJECTID);
  try{sub = subService.newSubscription(subscriptionName,topicName,webhookUrl)}
  catch(e){sub = subService.getSubscription(subscriptionName,topicName,webhookUrl)}
  return sub;
}


function getTokenService(){
  var jsonKey = JSON.parse(PropertiesService.getScriptProperties().getProperty("jsonKey"));  
  var privateKey = jsonKey.private_key;
  var serviceAccountEmail = jsonKey.client_email; 
  var sa = GSApp.init(privateKey, ['https://www.googleapis.com/auth/pubsub'], serviceAccountEmail);
  sa.addUser(serviceAccountEmail)
  .requestToken();
  return sa.tokenService(serviceAccountEmail);
}


function requestGmailScope_(){GmailApp.getAliases()}

Solution

  • The "Register in Chrome Web Store" option is only available in the standalone scripts. Meaning, if this script is bound to a Google Sheets, Docs, Forms or scripts appear among your files in Google Drive, then this "Register in Chrome Web Store" is not available.

    You can verify it by checking the publish in this "https://www.google.com/script/start/". This one will have an option of "Register in Chrome Web Store" in the publish.

    While by checking the script editor of a spreadsheet, created in your Drive, the "Register in Chrome Web Store" will not be found in the Publish section.

    Hope this information helps you.