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

Allowing end users to install your app from Google Apps Marketplace

Wednesday, September 17, 2014 | 10:19 AM

Crossposted from the Google Developers Blog

by Chris Han, Product Manager Google Apps Marketplace

The Google Apps Marketplace brings together hundreds of third-party applications that integrate and enhance Google Apps for Work. Previously, only administrators were able to install these applications directly for people at work. Now, any Google Apps user can install these applications by logging into Google Apps, clicking the app launcher icon , clicking More, and then clicking More from Apps Marketplace. By default, any Google Apps user can install apps from the Google Apps Marketplace—excluding K-12 EDU domains that are defaulted off. For more information, please see our Help Center
If you have an app in the Google Apps Marketplace utilizing oAuth 2.0, you can follow the simple steps below to enable individual end users to install your app. If you’re not yet using oAuth 2.0, instructions to migrate are here.

1. Navigate to your Google Developer Console.

2. Select your Google Apps Marketplace project.
3. Click APIs under the APIs & auth section.
4. Click the gear icon next to Google Apps Marketplace SDK.
5. Check Allow Individual Install.
6. Click Save changes.

How to move your files to Google Drive

Thursday, August 21, 2014 | 9:27 AM

Google Drive for Work is a new premium offering for businesses that includes unlimited storage, advanced audit reporting and new security controls and features, such as encryption at rest.

If you're getting ready to move your company to Drive, one of the first things on your mind is how to migrate all your existing files with as little hassle as possible. It's easy to migrate your files by uploading them directly to Drive or using the Drive Sync client. But, what if you have files stored elsewhere that you want to consolidate? Or what if you want to migrate multiple users at once? Many independent software vendors (ISVs) have built solutions to help organizations migrate their files from different File Sync and Share (FSS) solutions, local hard drives and other data sources. Here are some of the options available for you to use:
  • Cloud Migrator, by Cloud Technology Solutions, migrates user accounts and files to Google Drive and other Google Apps services. (websiteblogpost)
  • Cloudsfer, by Tzunami, transfers files from Box, Dropbox and Microsoft OneDrive to Google Drive. (website)
  • Migrator for Google Apps, by Backupify, migrates and consolidates personal Google Drive or other Google Apps for Business accounts into a single domain. (websiteblogpost)
  • Mover migrates data from 23 cloud services providers, web services, and databases into Google Drive. (websiteblogpost)
  • Nava Certus, by LinkGard, provides a migration and synchronization solution for on-premise and cloud-based storage platforms, including Dropbox, Microsoft OneDrive, Amazon S3, as well as local file systems. (website,blogpost)
  • SkySync, by Portal Architects, integrates existing on-site storage systems as well as other cloud storage providers to Google Drive. (websiteblogpost)
These are just a few companies that offer migration solutions. Please visit the Google Apps Marketplace for a complete listing of tools and offerings that add value to the Google Apps platform.

Advanced security for Google Drive for Work

Wednesday, July 23, 2014 | 9:10 AM

Labels: ,

Last month we announced Google Drive for Work, which includes advanced Drive auditing to give organizations control, security and visibility into how files are shared. This new security feature helps companies and IT managers protect confidential information and gain insights into how their employees work.

Drive audit helps IT admins view activity on documents, such as uploading and downloading files, renaming files, editing and commenting, and sharing with others. Filters make it easy to sort and find details like IP address, date range, document title and owner’s email address. To make advanced auditing reports easier to manage, admins can set up alerts for important events like files being shared outside the organization.

To help organizations derive even more value from Drive for Work, we’ve been working with partners to give you even more capabilities through the Drive Audit API:

  • Backupify protects your Google Apps data through secure, automatic, daily backup allowing IT users to easily search and restore files with advanced administrative features, safeguarding your business from data loss caused by user errors, malicious deletions, hackers, and app errors. (website, blogpost)
  • BetterCloud, through their flagship cloud management and security tool, FlashPanel, has enhanced their offering through the Audit API to provide additional controls and insight. (website, blogpost)
  • CloudLock, who provides a pure-cloud Data Loss Prevention (DLP) solution for SaaS applications, has released a new version of CloudLock for Google Drive, leveraging the new Google Drive audit APIs, to enable large organizations to extend their enterprise security controls to the cloud. (website, blogpost)
  • SkyHigh for Google Drive delivers Data Loss Prevention (DLP), mobile-to-cloud support, application auditing, data discovery, and anomaly detection without changing the Google Drive experience users love. (website, blogpost)
And this is only the beginning. We invite developers and customers alike to get started with the Audit API to provide additional advanced security solutions for Google Drive. Learn more by visiting

Google is committed to enabling organizations to be successful by leveraging a large community of ISVs. One of the areas we constantly invest in is our APIs, that allow customers and ISVs to extend the functionality of the Google Apps platform. If you’d like to join our ISV community, check out the site. For a list of ISVs supporting Google Apps, please visit the Google Apps Marketplace.

Upgrade now to Calendar APIv3

Thursday, July 17, 2014 | 11:30 AM


Back in 2011, we launched Calendar APIv3, which offers developers several improvements over older versions of the API, including better support for recurring events and lightweight resource representation in JSON.

At that same time, we also announced that the older versions of the API – v1 and v2 – would be entering a three-year deprecation period in order to give developers time to migrate to the new version. Those three years are coming to an end, and on November 17, the v1 and v2 endpoints will be shut down. If you haven’t already done so, you should migrate your application now to APIv3 so that it continues to work after that date (and to start taking advantage of all that the new API offers!).

For additional resources, check out our Migration and Getting started guides. And if you have questions or issues, please reach out to us on, using tag #google-calendar.

By Lucia Fedorova, Calendar API Team

Lucia Fedorova is a Tech Lead of the Google Calendar API team. The team focuses on providing a great experience to Google Calendar developers and enabling new and exciting integrations.

Introducing the new Gmail API

Wednesday, June 25, 2014 | 11:00 AM


For a while now, many of you have been asking for a better way to access data to build apps that integrate with Gmail. While IMAP is great at what it was designed for (connecting email clients to email servers in a standard way), it wasn’t really designed to do all of the cool things that you have been working on, which is why this week at Google I/O, we’re launching the beta of the new Gmail API.

Designed to let you easily deliver Gmail-enabled features, this new API is a standard Google API, which gives RESTful access to a user’s mailbox under OAuth 2.0 authorization. It supports CRUD operations on true Gmail datatypes such as messages, threads, labels and drafts.

As a standard Google API, you make simple HTTPS calls and get your responses in JSON, XML or Google Protobuf formats. You can also make these calls from standard web languages like Java and Python without using a TCP socket, which means the API is accessible from many cloud environments that couldn’t support IMAP.

In contrast to IMAP, which requires access to all of a user’s messages for all operations, the new API gives fine-grained control to a user’s mailbox. For example, if your app only needs to send mail on behalf of a user and does not need to read mail, you can limit your permission request to send-only.

To keep in sync, the API allows you to query the inbox change history, thereby avoiding the need to do “archaeology” to figure out what changed.

Finally, a huge benefit is speed. While there’s still some tuning to be done (“beta” - remember?), results from our tests and feedback from pre-release developers suggest that the new Gmail API is delivering dramatic performance improvements over IMAP for web application use cases.

Check out the launch video and get started with samples, tutorials, and API references at We can’t wait to see what you build.

Posted by Eric DeFriez, Gmail Extensibility Team. As a technical lead for Gmail APIs, Eric works to make it easy for developers to build on top of Gmail.

Guest Post: Integrating with Google Drive via a Chrome Web Store App

Tuesday, June 24, 2014 | 2:00 PM


This post is prepared by Nina Gorbunova, Teamlab Office Marketing Manager

About Teamlab Personal
Teamlab Personal is a suite of online document editors free for individual use. We've recently implemented two way integration with Google Drive and would like to share our experience.

Why Google Drive integration
Many of our users connect Google Drive to Teamlab, and we wanted to reach more by being in the Chrome Web Store. The availability of Google Drive SDK and Google Drive API helped us fit it all together. We thought: if a user can connect a Google Drive account to Teamlab Personal, why not build a return path? In the eyes of users, it is an enhancement of their Drive accounts. They get an opportunity to process documents using high formatting quality in browser and to make one more step away from desktop apps.

Integration goals
From the technical side, here is what we wanted to do:

  • Integrate Teamlab editors and viewers with Google Drive.
  • Provide co-editing opportunities.
  • Enable file conversion and creating new files in the common Office Open XML format.
  • Enable users to login with Google to use Teamlab Personal.
Five steps to achieve two-way integration
  1. We registered with Google’s developer console, added our project and connected the Drive API and Drive SDK to the app.
  2. Then we needed to decide what scopes our app needed to access the Google Drive API. We chose the minimal set, ample for us to access the files to edit without trespassing the user’s privacy (most users are not likely to provide full access to 3rd party apps)

  3. Because we work with traditional office apps, we chose docx, xlsx and pptx formats as default file extensions for our app. We also added secondary formats: ppt, pps, odp, doc, odt, rtf, txt, xls, csv, ods, mht, html, htm, fb2, epub, pdf, djvu.
  4. The current listing for the pre-existing app, we modified the code and added the following to the manifest: "container" : "GOOGLE_DRIVE","api_console_project_id" : "YOUR_APP_ID". Once a user installs Teamlab Personal app from Chrome Web Store, it automatically connects to their Google Drive account.
  5. Finally, Teamlab Personal uses OAuth 2.0 for authorization and file access. The application processes requests for creating and opening files.
How it works
As soon as you've installed Teamlab Personal from the Chrome Web Store, the integration automatically activates. Now, you can choose the Teamlab icon when creating new and editing the existing documents.

If the user selects the Teamlab editor as the default, .docx, .xlsx and .pptx files are opened in Teamlab automatically. For other documents, we create a copy in Office Open XML format which will be saved on Drive alongside the original.

Requests processing at

When a file is opened or created on Google Drive using the Teamlab Personal application, the handler gets the request with the following parameters: "ids" ("folderId" if case of file creation), "action", "userId" and "code". The "code" parameter is used to get the authentication token via OAuth 2.0 protocol (with the help of the request to with the "client_id", "client_secret", "redirect_ur parameters", and the additional "grant_type=authorization_code" parameter from the developer console). The received token is used in the subsequent requests. The "ids" parameter is the file to be opened identifier which is sent to the address in JSON format. The returned "mimeType" and "downloadUrl" are used to get the file content. That's all what is needed to open the document file in Office Open XML format (.docx, .xlsx or .pptx) in Teamlab.

Files in other formats are converted to the corresponding Office Open XML format and a copy is saved to the Drive folder prior to opening. In this case the "downloadUrl" is used to get the original file. The file is saved with the help of the POST request to the address. In this request the "ContentType" is set as "multipart/related; boundary=boundary" and the request body contains the file information placed before the main request content.

Request code:

string CreateFile(Stream content, string fileName, string mimeType, string folderId, string accessToken){
    var bytes = Encoding.UTF8.GetBytes(
        "\r\n--boundary\r\nContent-Type: application/json; charset=UTF-8\r\n\r\n{\"title\":\""
        + fileName + "\",\"parents\":[{\"id\":\"" + folderId + "\"}]}"
        + "\r\n--boundary\r\nContent-Type: " + mimeType + "\r\n\r\n");

    var tmpStream = new MemoryStream();
    tmpStream.Write(bytes, 0, bytes.Length);

    bytes = Encoding.UTF8.GetBytes("\r\n--boundary--\r\n");
    tmpStream.Write(bytes, 0, bytes.Length);

    var request = WebRequest.Create("");
    request.Method = "POST";
    request.Headers.Add("Authorization", "Bearer " + accessToken);
    request.ContentType = "multipart/related; boundary=boundary";
    request.ContentLength = tmpStream.Length;

    var buffer = new byte[2048];
    int readed;
    tmpStream.Seek(0, SeekOrigin.Begin);
    while ((readed = tmpStream.Read(buffer, 0, 2048)) > 0) {
        request.GetRequestStream().Write(buffer, 0, readed);
    return request.GetResponse().GetResponseStream();

The "Works with Google Drive" label does its magic indeed. We strongly recommend other developers build a Chrome Web Store app, as the results are clear and valuable. We had a high jump in installs (see the graph below) after we completed our integration. Teamlab Personal website traffic doubled and we received more than enough of users’ feedback – great impact for further development.

Google Chrome Web Store Impressions&Installations Statistics. Launch - April.

About the author
Nina started her career at Teamlab in 2011 as an intern. She is now a Senior Marketing Manager at Teamlab Office.