Reminder: ScriptDB is shutting down soon

Monday, October 13, 2014 | 8:56 AM

Back in May, we announced that ScriptDB, an experimental database in Google Apps Script, would be turned off on November 20, 2014.  Hopefully you've already migrated your data to another database, but if not, now is the time to check out alternatives like Cloud SQL. The migration guide explains how to export your data from ScriptDB.We’ve also improved the documentation for connecting to external databases through JDBC, makingit easier for you to set up Cloud SQL with Apps Script.

To summarize: ScriptDb will shut down on November 20, 2014, so please ensure you migrate your scripts before then!

Posted by Saurabh Gupta, Product Manager, Google Apps Script

Updates on Authentication for Gmail IMAP, POP, and SMTP

Monday, October 6, 2014 | 11:54 AM

Labels: ,

We’d like to highlight some recent and upcoming changes around authentication for Gmail IMAP, POP, and SMTP.

Additional Scrutiny for Password Authentication 
As previously announced, Google has begun increasing the security checks that occur when logging in with a user’s Google password. This includes access via Gmail IMAP, POP, and SMTP-MSA. It does not apply when authenticating with OAuth 2.0 via the XOAUTH2 mechanism.

If the checks detect anything suspicious about a password login attempt, our servers may deny login and return an error message requesting that the user first login to Google through a web browser. They may also require the user to explicitly enable “Less Secure Apps” on their account. Applications that perform password authentication to IMAP, POP, or SMTP are examples of "Less Secure Apps".

We strongly encourage developers to use OAuth 2.0 (via the XOAUTH2 mechanism for IMAP, POP, and SMTP) in order to better protect their users.

XOAUTH support ends May 5, 2015 
The OAuth 1.0 XOAUTH authentication mechanism for Gmail IMAP and SMTP-MSA is deprecated and will stop being supported on May 5, 2015. Developers must migrate to XOAUTH2 in order to continue authenticating to Gmail after that date. You can migrate existing users without their intervention by following the instructions in this migration guide. Instructions for developing your XOAUTH2 code are in the XOAUTH2 documentation.

Posted by Jamie Nicolson, Gmail Software Engineer

Installable triggers in add-ons for Google Docs and Sheets

Wednesday, October 1, 2014 | 12:04 PM


Update (Oct 17, 2014): Add-ons can now also use time-driven triggers.

Earlier this year, we introduced add-ons for Google Docs and Sheets—packaged Apps Script projects that users can easily install from our add-on store to get extra functionality and features.
Since then, plenty of developers told us they were eager to add installable Apps Script triggers to their add-ons. We're happy to announce that now you can do just that, making it possible to respond to more user actions. For example, a spreadsheet add-on can now react when a user submits a response to a Google Form, or can call a method that requires authorization when a user edits a cell.
Add-ons can now programmatically create and manage these installable triggers:

  • Sheets add-ons can use the change, edit, open, and form-submit installable triggers.
  • Docs add-ons can use the (new!) open installable trigger.
To see the power of installable triggers in action, check out developer Romain Vialard's Yet Another Mail Merge, which has already been updated. The original YAMM lets users quickly personalize Gmail drafts by replacing placeholder fields with data from a spreadsheet. The new version uses a trigger to send an email whenever a form is submitted.
If you've worked with installable triggers before, you'll find that they behave a little differently in add-ons (for one thing, there are no pesky "Summary of failures" emails!), so be sure to check out the documentation.
Posted by Edward Jones, Googler

Sudoku, Linear Optimization, and the Ten Cent Diet

Tuesday, September 30, 2014 | 10:02 AM


Originally posted on the Google Research blog. Cross posted on the Google Developers blog

In 1945, future Nobel laureate George Stigler wrote an essay in the Journal of Farm Economics titled The Cost of Subsistence about a seemingly simple problem: how could a soldier be fed for as little money as possible?

The “Stigler Diet” became a classic problem in the then-new field of linear optimization, which is used today in many areas of science and engineering. Any time you have a set of linear constraints such as “at least 50 square meters of solar panels” or “the amount of paint should equal the amount of primer” along with a linear goal (e.g., “minimize cost” or “maximize customers served”), that’s a linear optimization problem.

At Google, our engineers work on plenty of optimization problems. One example is our YouTube video stabilization system, which uses linear optimization to eliminate the shakiness of handheld cameras. A more lighthearted example is in the Google Docs Sudoku add-on, which instantaneously generates and solves Sudoku puzzles inside a Google Sheet, using the SCIP mixed integer programming solver to compute the solution.

Today we’re proud to announce two new ways for everyone to solve linear optimization problems. First, you can now solve linear optimization problems in Google Sheets with the Linear Optimization add-on written by Google Software Engineer Mihai Amarandei-Stavila. The add-on uses Google Apps Script to send optimization problems to Google servers. The solutions are displayed inside the spreadsheet. For developers who want to create their own applications on top of Google Apps, we also provide an API to let you call our linear solver directly.

Second, we’re open-sourcing the linear solver underlying the add-on: Glop (the Google Linear Optimization Package), created by Bruno de Backer with other members of the Google Optimization team. It’s available as part of the or-tools suite and we provide a few examples to get you started. On that page, you’ll find the Glop solution to the Stigler diet problem. (A Google Sheets file that uses Glop and the Linear Optimization add-on to solve the Stigler diet problem is available here. You’ll need to install the add-on first.)

Stigler posed his problem as follows: given nine nutrients (calories, protein, Vitamin C, and so on) and 77 candidate foods, find the foods that could sustain soldiers at minimum cost.

The Simplex algorithm for linear optimization was two years away from being invented, so Stigler had to do his best, arriving at a diet that cost $39.93 per year (in 1939 dollars), or just over ten cents per day. Even that wasn’t the cheapest diet. In 1947, Jack Laderman used Simplex, nine calculator-wielding clerks, and 120 person-days to arrive at the optimal solution.

Glop’s Simplex implementation solves the problem in 300 milliseconds. Unfortunately, Stigler didn’t include taste as a constraint, and so the poor hypothetical soldiers will eat nothing but the following, ever:
  • Enriched wheat flour
  • Liver
  • Cabbage
  • Spinach
  • Navy beans
Is it possible to create an appealing dish out of these five ingredients? Google Chef Anthony Marco took it as a challenge, and we’re calling the result Foie Linéaire à la Stigler:

This optimal meal consists of seared calf liver dredged in flour, atop a navy bean purée with marinated cabbage and a spinach pesto.

Chef Marco reported that the most difficult constraint was making the dish tasty without butter or cream. That said, I had the opportunity to taste our linear optimization solution, and it was delicious.

New Google Apps Activity API

Thursday, September 25, 2014 | 10:29 AM

This post was originally posted on the Google Developer Blog

Back in January, Google Drive launched an activity stream that shows you what actions have been taken on files and folders in your Drive. For example, if someone makes edits on a file you’ve shared with them, you’ll see a notification in your activity stream.

Today, we’re introducing the new Google Apps Activity API designed to give developers programmatic access to this activity stream. This standard Google API will allow apps and extensions to access the activity history for individual Drive files as well as descendents of a folder through a RESTful interface.

The Google Apps Activity API will allow developers to build new tools to help users keep better track of what’s happening to specific files and folders they care about. For example, you might use this new API to help teachers see which students in their class are editing a file or, come tax season, you might want to create a quick script to audit the sharing of items in your financial information folder.

Check out the documentation at We can't wait to see what you build!

Posted by Justin Hicks, Software Engineer, Technical Lead for Google Apps Activity API

New features in Admin SDK: Custom user attributes, and opening up access to all domain users

Tuesday, September 23, 2014 | 11:23 AM

[ed: This post originally appeared on the Google Developers Blog]

By Muzammil Esmail, Product Manager, Google for Work

The Admin SDK provides a comprehensive directory experience for Google for Work customers to help them meet specific business needs around data storage for customers. Here are some important updates to this SDK.

Custom attributes in the user’s profile
Now available is a new feature in the Directory API which allows you to add custom attributes for your users. For instance, you could store the projects your users work on, their desk number, job level, hiring date — whatever makes sense for your business.

Once the custom attributes for your domain have been defined, they behave just like regular fields in the user profile. You can get and set them for your users and also perform searches on custom fields (e.g. “all employees that work on the shinyNewApp in Hyderabad”).

Custom attributes can be of different data types; they can be single- or multi-valued. You can configure whether they are “public” i.e. visible to everyone on the domain, or “private” i.e. visible only to admins and the users themselves.

Read access to all domain users
Historically, only admins have been able to access the data in the Admin SDK. Beginning today, any user (not just admins) will now be able to call the Directory API to read the profile of any user on the domain (of course, we will respect ACLing settings and profile sharing settings).

We hope that you will be able to use this new feature to build business applications (e.g. corporate yellow pages, expense approval, vacation management, workflow applications, etc.) that can be used by all your users.

Please feel free to go through our documentation to go learn more about the Admin SDK, and specifically the Directory API. Happy hacking!

Change in Apps Script's DocsListDialog

Thursday, September 18, 2014 | 9:00 AM


DocsListDialog is a widget used by only a small fraction of Apps Script projects to provide a Google Drive "file open" dialog in a UI service user interface. In almost all cases, using Google Picker in HTML service is preferable and more secure.

Before September 30, 2014, we require scripts using DocsListDialog to make a small update to improve security.

Specifically, if you use DocsListDialog, you'll need to start calling a new method, setOAuthToken(oAuthToken) before you call showDocsPicker(). The new method sets an OAuth 2.0 token to use when fetching data for the dialog, on behalf of the user whose content should be shown.

So long as the app isn't a web app set to execute as "me" (the developer), you can get the necessary OAuth 2.0 token by calling ScriptApp.getOAuthToken(). The example below shows how to convert an old DocsListDialog implementation to the new model.

Old example

function showDialog() {
  var app = UiApp.createApplication();


     .showModalDialog(app,' ');

New example

function showDialog() {
  var app = UiApp.createApplication();

     .showModalDialog(app,' ');

To ensure your script continues to work properly, be sure to make this change before September 30.

Posted by Dan Lazin, Googler