2

I have a Google sheet with a Container-bound Script that makes Google Classroom API calls. I have added the spreadsheet now as a template for all teachers in my organization to copy the sheet and use it for themselves.

However, when teachers copy from the template, a new project is created in Google Console with no enabled APIs for that new project. They would have to go into the developer console and enable Classroom API for it to work....

No! This is way too much of a hassle for my fellow teachers! There has to be a better way. What am I doing wrong? How can my script keep the API calls enabled for all copies of the spreadsheet? Do I need to publish my script in a particular way or set up my project in a particular way? Whats the right approach here, guys?

This error when using the script in a copied spreadsheet. But of course, works fine in the original template file.

Google Classroom API has not been used in project project-id-xxxxxxxxxxxxxxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/classroom.googleapis.com/overview?project=project-id-xxxxxxxxxxxxxxxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

1 Answers1

3

You should publish your script as Sheets Add-on: https://developers.google.com/apps-script/add-ons/

This gives you next benefits:

  1. when spreadsheet (with enabled add-on) is copied, there's no need to manually enable APIs, they are stay enabled;
  2. when you update code of your add-on, it is automatically updated for all spreadsheets where it was enabled, so you don't have to copy your changes manually.
Kos
  • 4,890
  • 9
  • 38
  • 42
  • Your answer makes sense. But it's not working for me.... I published the addon. Enable the addon on the speadsheet. I make copies of the spreadsheet. I click an image button to activate a script, it asks for permissions, I allow it.... and then I get "Google Classroom API has not been used in project project-id-xxxxxxxxxxxx before or it is disabled. ....blah blah" Do I have to redo a template spreadsheet using the addon only? – Martin Vivian Dec 07 '17 at 00:57
  • If I make another spreadsheet and enable the addon in it. It works great! But if I try to use that as a template, then copies of this spreadsheet don't come with the addon enabled. I want the addon, tied to the spreadsheet and it copies! – Martin Vivian Dec 07 '17 at 03:14
  • I think I might need to submit it as a proper template rather than just copying it. This actually might be the issue. – Martin Vivian Dec 07 '17 at 03:31
  • 1
    > Do I have to redo a template spreadsheet using the addon only? Certainly – Kos Dec 07 '17 at 09:15