Author Archives: Google Apps Developer Blog Editor

Programmatically transfer ownership of Google+ pages and Google Drive content

Google Apps users generate a lot of content at work—project plans, design documents, client presentations, and more. Many of these files are still relevant to an employee’s company or team even after he or she has left or transferred internally. The new Data Transfer API will make it easier for developers to build tools that will allow admins to better manage their end-user data, specifically apps that can transfer ownership of Google Docs, Sheets, and Slides, and all the other Google Drive files as well as Google+ pages in your Google for Work account—in bulk—from one employee/end-user to another using the API.

In July, we introduced the Data Transfer privilege, which makes it easier for admins to transfer data ownership. That same privilege is leveraged by the Data Transfer API. When enabled, it allows admins to programmatically migrate file ownership anytime they want using the API—provided they’ve enabled API access. In order to transfer ownership of Google Drive content as well as Google+ pages, super admins will need to grant/delegate the Data Transfer privilege to admins before end-user content can be migrated programmatically (via API or 3rd-party tools) or from the admin console.


This is what User Deletion looks like in the Administration console,
but now you can also do this programmatically with the API.

To get started with the Data Transfer API, take a look at the developer documentation. Keep in mind that while this programmatic feature is new, admins can still transfer user data manually from the admin console. For more general information, see the Help Center pages on transferring file ownership on Google Drive and how to delete a user.

Google Calendar API invites users to great experiences

Originally posted on the Google Developers Blog.

Posted by Wesley Chun, Developer Advocate

Have you ever booked a dining reservation, plane ticket, hotel room, concert ticket, or seats to the game from your favorite app, only to have to exit that booking app to enter the details into your calendar? It doesn’t make for a friendly user experience. Why can’t today’s apps do that for you automatically?

In case you missed it the episode 97 of #GoogleDev100 the other week, I aim to inspire how app developers can streamline that process with the help of the Google Calendar API. A short Python script, anchored by the following snippet, is illustrated to show developers how easy it is to programmatically add calendar events:


CALENDAR = apiclient.discovery.build('calendar', 'v3', http=creds.authorize(Http()))
GMT_OFF = '-07:00' # PDT/MST/GMT-7
EVENT = {
'summary': 'Dinner with friends',
'start': {'dateTime': '2015-09-18T19:00:00%s' % GMT_OFF},
'end': {'dateTime': '2015-09-18T22:00:00%s' % GMT_OFF},
'attendees': [
{'email': '[email protected]'},
{'email': '[email protected]'},
],
}
CALENDAR.events().insert(calendarId='primary', body=EVENT).execute()


For deeper dive into the script, check out the corresponding blogpost. With code like that, your app can automatically insert your relevant events into your users’ calendars, saving them the effort of manually doing it themselves. One of the surprising aspects is that a limited set of actions, such as RSVPing, is even available to non-Google Calendar users. By the way, inserting events is just the beginning. Developers can also delete or update events instantly in case that upcoming dinner gets pushed back a few weeks. Events can even be repeated with a recurrence rule. Attachments are also supported so you can provide your users a PDF of the concert tickets they just booked. Those are just some of the things the API is capable of.

Ready to get started? Much more information, including code samples in Java, PHP, .NET, Android, iOS, and more, can be found in the Google Calendar API documentation. If you’re new to the Launchpad Online developer series, we share technical content aimed at novice Google developers… the latest tools and features with a little bit of code to help you launch that app. Please give us your feedback below and tell us what topics you would like to see in future episodes!

Google Apps Marketplace gets a fresh new look

Posted by, Chris Han, Product Manager Google Apps Marketplace

The Google Apps Marketplace brings together hundreds of third-party applications that integrate with and enhance Google Apps for Work. It’s a great place to get discovered by more than five million Google Apps customers. Many of these customers depend on Google Apps Marketplace to find the solutions their organizations need, driving millions of users to the top listed apps.

Today, we’ve launched a brand new Google Apps Marketplace site aimed to improving discoverability and getting your app installed by even more customers. No need to do anything if you’ve already listed your app publicly on Google Apps Marketplace. Your app will appear on the new site automatically.

If you haven’t listed your app yet on Google Apps Marketplace, follow these instructions to get started!


Deprecating web hosting support in Google Drive

Beginning August 31st, 2015, web hosting in Google Drive for users and developers will be deprecated. You can continue to use this feature for a period of one year until August 31st, 2016, when we will discontinue serving content via googledrive.com/host/[doc id].

In the time since we launched web hosting in Drive, a wide variety of public web content hosting services have emerged. After careful consideration, we have decided to discontinue this feature and focus on our core user experience.

For those who have used Drive to host websites, Google Domains can refer you to third parties for website hosting functionality.

For those who use this feature to serve non-user content to web and mobile applications, Google Cloud Platform offers a better-performing solution.

Real-time notifications in add-ons with Firebase

Editor's note: Posted by Romain Vialard, a Google Developer Expert and developer of Yet Another Mail Merge, a Google Sheets add-on.

Yet Another Mail Merge is a Google Sheets add-on that lets users send multiple personalized emails based on a template saved as a draft in Gmail and data in a Google Sheet. It can send hundreds of emails, but this kind of operation usually takes a few minutes to complete. This raises the question: what should be displayed in the user interface while a function is running on server side for a long time?


Real-time notifications in Add-ons

Firebase is all about real-time and became the answer to that issue. Last December, the Apps Script team announced a better version of the HtmlService with far fewer restrictions and the ability to use external JS libraries. With Firebase, we now had a solution to easily store and sync data in real-time.

Combined, users are able to know, in real-time, the number of emails sent by an Apps Script function running server-side. When the user starts the mail merge, it calls the Apps Script function that sends emails and connects to Firebase at the same time. Every time the Apps Script function has finished sending a new email, it increments a counter on Firebase and the UI is updated in real-time, as shown in the following image.


Implementation

Inside the loop, each time an email is sent (i.e. each time we use the method GmailApp.sendEmail()), we use the Apps Script UrlFetch service to write into Firebase using its REST API. Firebase's capabilities makes this easy & secure and there’s no need for an OAuth Authorization Flow, just a Firebase app secret, as shown in the following example:

function addNewUserToFirebase() {
var dbUrl = "https://test-apps-script.firebaseio.com";
var secret = PropertiesService.getScriptProperties().getProperty("fb-secret");
var path = "/users/";
var userData = {
romainvialard:{
firstName:"Romain",
lastName:"Vialard",
registrationDate: new Date()
}
};
var params = {
method: "PUT",
payload : JSON.stringify(userData)
}
UrlFetchApp.fetch(dbUrl + path + ".json?auth=" + secret, params);
}

On the client side, thanks to the improved Apps Script HtmlService, we can use the official JS client library to connect to Firebase and retrieve the data stored previously. Specifically, the on() method in this library can be used to listen for data changes at a particular location in our database. So each time a new task is completed on server side (e.g. new email sent), we notify Firebase and the UI is automatically updated accordingly.

var fb = new Firebase("https://test-apps-script.firebaseio.com");
var ref = fb.child('users/' + UID + '/nbOfEmailsSent');
ref.on("value", function(data) {
if (data.val()) {
document.getElementById("nbOfEmailsSent").innerHTML = data.val();
}
});

More Firebase in Add-ons

In addition to the example above, there are other places where Firebase can be useful in Google Apps Script add-ons.

  • “Yet Another Mail Merge” also offers paid plans and it needs to store our customer list. It turns out, Firebase is perfect for that as well. Each time someone buys a plan, our payment tool calls an Apps Script web app which writes the payment details in Firebase. So right after the purchase, the user can open the add-on and a function on server side will call Firebase and see that premium features should now be enabled for this user.
  • Last but not least, at the end of a mail merge, we also use Firebase to provide real-time reporting of emails opened, directly in the sidebar of the spreadsheet.

Those are just a few examples of what you can do with Apps Script and Firebase. Don’t hesitate to try it yourself or install Yet Another Mail Merge to see a live example. In addition, there is a public Apps Script library called FirebaseApp that can help you start with Firebase; use it like any other standard Apps Script library.

For example, you can easily fetch data from Firebase using specific query parameters:

function getFrenchContacts() {
var firebaseUrl = "https://script-examples.firebaseio.com/";
var base = FirebaseApp.getDatabaseByUrl(firebaseUrl);
var queryParameters = {orderBy:"country", equalTo: "France"};
var data = base.getData("", queryParameters);
for(var i in data) {
Logger.log(data[i].firstName + ' ' + data[i].lastName
+ ' - ' + data[i].country);
}
}

Build your own add-ons via Google Apps Script. Check out the documentation (developers.google.com/apps-script) to get more information as well as try out the Quickstart projects there. We look forward to seeing your add-ons soon!


Romain Vialard profile | website

Romain Vialard is a Google Developer Expert. After some years spent as a Google Apps consultant, he is now focused on products for Google Apps users, including add-ons such as Yet Another Mail Merge and Form Publisher.

New ways to integrate with Google Classroom

Classroom debuted last year to help teachers and students save time and collaborate with each other, and since then we’ve been working on how to make sure it worked well with other products that educators love and use in their classes.

Starting today, developers can embed the Classroom share button and sign up for the developer preview of the Classroom API. These tools make it easy for developers to seamlessly integrate with Classroom in ways that help teachers and students — like letting teachers create assignments directly from Quizlet, Duolingo, PBS and many other favorites.


Classroom API

By using the API, admins will be able to provision and populate classes on behalf of their teachers, set up tools to sync their Student Information Systems with Classroom, and get basic visibility into which classes are being taught in their domain. The Classroom API also allows other apps to integrate with Classroom.

Until the end of July, we’ll be running a developer preview, during which interested admins and developers can sign up for early access. When the preview ends, all Apps for Education domains will be able to use the API, unless the admin has restricted access.

A few developers have been helping us test the API, and we’re excited to share a few examples of what they’ve built:

  • The New Visions CloudLab (makers of Doctopus) built rosterSync for Sheets, an add-on integrated with Classroom. Harnessing the power of Google Sheets, admins can sync data from any student information system with Classroom.
  • Alma, a hybrid student information and learning management platform, will let schools easily create and sync their class rosters directly to Classroom with just a few clicks. And if an admin adds a student to a class in Alma, that student will get automatically added in the Classroom class. See more in their demo video.
  • And if you use Pear Deck, it’s now easy to start an interactive Pear Deck session with any of your Classroom classes. Just click “Invite from Google Classroom,” choose a class and your students will automatically be invited. Pear Deck will always use your current roster of students from Classroom, so you don’t have to keep rosters up to date across apps.

Classroom share button

Today we’re also introducing the Classroom share button, a simple way for developers – or schools – to allow teachers and students to seamlessly assign or turn-in links, videos and images from another webpage or product.

The share button only requires a few lines of JavaScript, and you can customize the button to meet the needs of your website. When teachers and students click the button, they can quickly share to Classroom without having to leave the site they’re on. More than 20 educational content and tool providers have already committed to integrating the Classroom share button, including:

To get started or learn more about either the API or integrating the share button, visit developers.google.com/classroom. And let us know what you’re building using the #withclassroom hashtag on Twitter or G+. As always, we’re looking forward to hearing your feedback and making sure that we’re addressing top needs. We’ll use the developer community site Stack Overflow to field technical questions and feedback about the Classroom API. Please use the tag google-classroom.

Attach Google Drive files to Calendar events with the Calendar API

The Google Calendar API allows you to create and modify events on Google Calendar. Starting today, you can use the API to also attach Google Drive files to Calendar events to make them—and your app—even more useful and integrated. With the API, you can easily attach meeting notes or add PDFs of booking confirmations to events.

Here's how you set it up:

1) Get the file information from Google Drive (e.g. via the Google Drive API):

GET https://www.googleapis.com/drive/v2/files

{
...
"items": [
{
"kind": "drive#file",
"id": "9oNKwQI7dkW-xHJ3eRvTO6Cp92obxs1kJsZLFRGFMz9Q,
...
"alternateLink": "https://docs.google.com/presentation/d/9oNKwQI7dkW-xHJ3eRvTO6Cp92obxs1kJsZLFRGFMz9Q/edit?usp=drivesdk",
"title": "Workout plan",
"mimeType": "application/vnd.google-apps.presentation",
...
},
...
]
}

2) Pass this information into an event modification operation using the Calendar API:

POST https://www.googleapis.com/calendar/v3/calendars/primary/events?supportsAttachments=true

{
"summary": "Workout",
"start": { ... },
"end": { ... },
...
"attachments": [
{
"fileUrl": "https://docs.google.com/presentation/d/9oNKwQI7dkW-xHJ3eRvTO6Cp92obxs1kJsZLFRGFMz9Q/edit?usp=drivesdk",
"title": "Workout plan",
"mimeType": "application/vnd.google-apps.presentation"
},
...
]
}

Voilà!

You don’t need to do anything special in order to see the existing attachments - they are now always exposed as part of an event:

GET https://www.googleapis.com/calendar/v3/calendars/primary/events/ja58khmqndmulcongdge9uekm7

{
"kind": "calendar#event",
"id": "ja58khmqndmulcongdge9uekm7",
"summary": "Workout",
...
"attachments": [
{
"fileUrl": "https://docs.google.com/presentation/d/9oNKwQI7dkW-xHJ3eRvTO6Cp92obxs1kJsZLFRGFMz9Q/edit?usp=drivesdk",
"title": "Workout plan",
"mimeType": "application/vnd.google-apps.presentation",
"iconLink": "https://ssl.gstatic.com/docs/doclist/images/icon_11_presentation_list.png"
},
...
]
}

Check out the guide and reference in the Google Calendar API documentation for additional details.

For any questions related to attachments or any other Calendar API features you can reach out to us on StackOverflow.com, using the tag #google-calendar.

On Air with the Google Apps Developer Team

Posted by Janet Traub, Program Manager, Google Apps APIs

The Google Apps Developer team recently hosted a 3-part Hangout On Air series that provided the developer community a unique opportunity to engage with the creative minds behind Google Apps developer tools. Each session covered topics ranging from business automation using Apps Script to Google Calendar API usage to creating Add-Ons for Docs & Sheets.

In the first installment of the series, Mike Harm, the creator of Apps Script and his colleague Kenzley Alphonse delivered a captivating session entitled, “Automate your Business with Apps Script.” Together, they reviewed the various features of Apps Script that can help developers build powerful solutions with Google Apps, such as simple scripts, to easily do a mail merge, export calendars into a Sheet, and to generate regularly scheduled reports.

The series then shifted focus to Google Calendar. In “Creating Calendar Events - Easy and Useful” Ali Ajdari Rad and Lucia Fedorova, product managers for Google Calendar, explained how developers can benefit from injecting content into users’ calendars. In addition, they reviewed different approaches on Google Calendar to create events and meetings, such as API features, email markups, Android intents, Calendar import, and more.

We concluded the series with “How to Increase Traffic to Your Add-On with Google Apps Script.” This session, delivered by Apps Script Product Manager, Saurabh Gupta and Mike Harm, gave developers an in depth understanding of the Add-Ons framework, steps to deployment and strategies to increase adoption of their Docs, Sheets and Forms Add-Ons.

For more information on developing for Google Apps, visit developers.google.com/google-apps

Gmail API Push notifications: don’t call us, we’ll call you

If your app needs to keep up with changes in a Gmail mailbox, whether it's new mail being received or a label being added, you are likely familiar with periodically polling the Gmail API's history feed for updates. If you find this tedious, we have good news for you. Today, at Google I/O 2015, we're launching push notifications for the Gmail API.

Just subscribe to a Gmail mailbox and whenever a change occurs, the Gmail API will instantly notify your server using webhooks or another Cloud Pub/Sub API notification method. No polling required.

Check out the developers’ guide at https://developers.google.com/gmail/api/guides/push to get started. 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.

Docs, Sheets and Forms add-ons now open to all developers

Posted by Saurabh Gupta, Product Manager

Originally posted to Google Developers blog

Back in 2014, we introduced add-ons for Google Docs, Sheets, and Forms in developer preview. Since then, the developer community has built a wide variety of features to help millions of Docs, Sheets and Forms users become more productive. Over the last few months, we launched a number of developer-friendly features that made it easier to build, test, deploy and distribute add-ons. Some key capabilities include:

With these features under our belt, we are ready to graduate add-ons out of developer preview. Starting today, any developer can publish an add-on. To ensure users find the best tools for them, every new add-on will undergo a review for adherence to our guidelines before it’s available in the add-ons store.

We can’t wait to see what you will build!