Wednesday, March 11, 2015
Exporting native Google documents with the Google Drive SDK
Three months ago, we launched Google Drive along with the Google Drive SDK. The SDK allows applications to manage files that users have uploaded to Drive and to integrate deeply in the Google Drive UI. Today, we’ve just extended the SDK to allow developers to interact with native Google Docs types such as Google Spreadsheets, Presentations, Documents, and Drawings.
We now provide an easy way to export native Google documents through the Google Drive API. We also allow native Google documents to be opened directly from within the Google Drive UI using third-party applications.
If your application is already a Drive-installable app, you can enable this feature by checking the Allow users to open files that can be converted to a format that this app can open option in the Google APIs Console under Drive SDK > Import:

When this feature is enabled, your application will show up under the “Open with” menu in the Google Drive Web UI for the file formats you support. Here’s how it works: if your application supports opening one of the possible export formats for the Google document, users will be able to open that Google document with your application. So for instance, if your application is configured to open PDF files, then because Google Documents are exportable to PDF, users will be able to use your application to open those documents as shown below.

When opening a native Google Document with your application from the Google Drive UI, we will pass the following JSON Object in the state
URL parameter of the OAuth 2.0 redirect request that is forwarding the user to your website.
{
"exportIds": ["file_id"],
"action":"open"
}
Then you can use the file ID contained in the JSON object to query the Google Drive API and fetch the file’s metadata. Note that the state
URL parameter is different when opening regular files as we use the JSON attribute exportIds
instead of ids
.
Unlike the metadata of regular files which contain a downloadUrl
attribute which you can use to download the file’s content, the metadata for native Google documents contains a collection of export URLs. These URLs - one for each supported export format - are listed under the attribute exportLinks
, as shown in the HTTP request/response below.
Request:
GET /drive/v2/files/<file_id> HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer <access_token>
Response:
HTTP/1.1 200 OK
Status: 200
...
{
"kind": "drive#file",
"id": "<file_id>",
...
"exportLinks": {
"application/vnd.oasis.opendocument.text": "https://docs.google.com/...",
"application/msword": "https://docs.google.com/...",
"text/html": "https://docs.google.com/...",
"application/rtf": "https://docs.google.com/...",
"text/plain": "https://docs.google.com/...",
"application/pdf": "https://docs.google.com/..."
},
...
}
You can query any of these export URLs using an authorized request to download the Google document in your prefered export format.
Below is the full list of supported export formats -- and their associated MIME types -- for the different types of native Google documents:
Google Documents:
- Text File (TXT) - text/plain
- Portable Document Format (PDF) - application/pdf
- OpenDocument Text Document (ODT) - application/vnd.oasis.opendocument.text
- Microsoft Word (DOC) - application/msword
- Hypertext Markup Language (HTML) - text/html
- Rich Text Format File (RTF) - application/rtf
Google Spreadsheets:
- Portable Document Format (PDF) - application/pdf
- Microsoft Excel Spreadsheet (XLS) - application/vnd.ms-excel
- OpenDocument Spreadsheet (ODS) - application/x-vnd.oasis.opendocument.spreadsheet
Google Presentations:
- Text File (TXT) - text/plain
- Portable Document Format (PDF) - application/pdf
- Microsoft Office Open XML Format Presentation (PPTX) - application/vnd.openxmlformats-officedocument.presentationml.presentation
Google Drawings:
- Scalable Vector Graphics (SVG) - image/svg+xml
- JPEG Images (JPEG) - image/jpeg
- Portable Network Graphics (PNG) - image/png
- Portable Document Format (PDF) - application/pdf
Please check out the Google Drive SDK documentation if you’d like to learn more, and feel free to ask any questions you may have on Stack Overflow.
Nicolas Garnier profile | twitter | events Nicolas Garnier joined Google’s Developer Relations in 2008 and lives in Zurich. He is a Developer Advocate focusing on Google Apps and Web APIs. Before joining Google, Nicolas worked at Airbus and at the French Space Agency where he built web applications for scientific researchers. |
Admin SDK and Google APIs for business
Today, were announcing the Admin SDK, which enables developers to build customized administrative tools for organizations that use Google Apps. The new Admin SDK consolidates many of the existing domain APIs into a new uniform structure and introduces new functionality with the Directory API and Reports API. We’re starting to pilot Google+ Domains API.
Directory API
The new Directory API provides a simple, RESTful interface to support all basic operations required to query & manage users, groups, organizational units, Chromebooks and mobile devices.Reports API
The new Reports API gives developers a consolidated view of reporting and auditing for domains. Developers can build applications that can monitor and search across usage statistics and activities within a domain.Google+ Domains API
Businesses are using Google+ to help employees collaborate more easily and get things done. Developers will soon be able to auto-provision Circles, read/write posts, and more from the new APIs. Let us know if youre interested in learning more about this API when its available.To begin using the Admin SDK follow the instructions in the API documentation. You will need to sign in to the Google APIs Console and activate the Admin SDK. If you have any questions, join the conversation at Stack Overflow.
Note about API deprecation:
With the introduction of the Directory and Reporting APIs in the new Admin SDK the following APIs will be deprecated per their standard deprecation policy: Google Apps Profiles, Provisioning, Admin Audit, Reporting, Reporting Visualization.
Ajay Guwalani Ajay Guwalani is Product Manager on Google Apps Admin APIs. His current focus is to build next generation admin APIs to make enterprise developers and admins happy. |
Monday, March 9, 2015
New security management features for domain users with the Admin SDK
We launched the Admin SDK in May as a new way for developers to build customized administrative tools for organizations that use Google Apps. A top priority for most administrators is keeping their users safe. Today, were adding new security management features to the Directory API to help administrators manage:
- Access granted by domain users to third-party applications
- Application specific passwords created by users
- Backup verification codes for users using 2-step verification.
As an example, FlashPanel, a popular tool used by Google Apps administrators, is using these new features to allow domain admins to review installed applications and manage or revoke access to them. The Apps Explorer in FlashPanel allows admins to see which are the most installed apps in his domain or use a filter to review applications by type of permissions (Drive, GMail, etc). It also allows admins to review the number of users who have granted access to a particular application.
The screenshot below shows an example of FlashPanel’s customized view of third-party application installs.
In FlashPanel’s integration, admins have the power to whitelist or blacklist apps, as shown below.
The Directory API now also provides the ability to manage admin notifications that are delivered to the Admin Console. Currently, admins receive notifications for events that affect their domains such as users approaching their storage limits or monthly bills that are due. Now you can use the API to list notifications, update their read status, or pull them into custom tools.
If you are interested in using these new endpoints, please refer to the Directory API documentation.
Ajay Guwalani Ajay Guwalani is Product Manager on Google Apps Admin APIs. His current focus is to build next generation admin APIs to make enterprise developers and admins happy. |
New Image Metadata for the Google Drive SDK
Do you like to store photos in Google Drive? You are not alone! Photographs are one of the most common file types stored in Google Drive. The Google Drive API now exposes Exif data for photos, so that Google Drive Apps can use it. The Exif data contains information about camera settings and photo attributes.
Despite being an awful photographer, I love photographing benches, and here is one I took while at the beach. Let’s have a look at some of these new fields for this photo.

When I examine the metadata for this image using a drive.files.get
call, there is now a field, imageMediaMetadata
, containing the detailed photo information:
"imageMediaMetadata": {
"width": 2888,
"height": 1000,
"rotation": 0,
"date": "2012:07:08 15:22:25",
"cameraMake": "NIKON CORPORATION",
"cameraModel": "NIKON D90",
"exposureTime": 8.0E-4,
"aperture": 5.6,
"flashUsed": false,
"focalLength": 105.0,
"isoSpeed": 200
}
So whether you are just storing your amateur snaps like me, or using Google Drive to store serious photographs, we hope this will be useful information for Drive apps. For example, a photo organizing application will be able to create thumbnail and information views for photos without ever having to download them.
For more information, please visit our documentation, and if you have any technical questions, please ask them on StackOverflow. Our team are waiting to hear from you.
![]() | Ali Afshar profile | twitter Tech Lead, Google Drive Developer Relations. As an eternal open source advocate, he contributes to a number of open source applications, and is the author of the PIDA Python IDE. Once an intensive care physician, he has a special interest in all aspects of technology for healthcare |