Migrating from Drive Activity API v1

This guide explains the differences between the v1 and v2 API versions and how to change your v1 application to support v2.

Authorization

The v1 API used the scope:

https://www.googleapis.com/auth/activity

The v2 API requires one of the following scopes:

https://www.googleapis.com/auth/drive.activity
https://www.googleapis.com/auth/drive.activity.readonly

Resource Names

In the v1 API, identifiers for objects like Drive items and users were opaque strings. In the v2 API, these objects are typically referenced using resource names; see the Cloud API Design Guide for more information.

These identifiers can generally be converted. For example, Drive items in the v2 API are referenced using the resource name items/V1_ITEM_ID.

Requests

The request format for v2 is largely similar to that of v1. Specifically, you can still request activity for a Drive file or a Drive ancestor, though note that you must format those request parameters as resource names by prefixing them with items/.

"Grouping" is now called "Consolidation", and the source and userId request parameters have been removed.

There are also new filtering options which allow you to constrain the types of activity data returned in the response.

Actors

In the v1 API, the returned activity contained a User if the actor was a known user, and optionally contained a top level field like fromUserDeletion for special cases.

In the v2 API, a richer set of Actor types is available, and user.knownUser is populated when the actor is a known user. If your application needs detailed information about users, it can query this from the People API by passing the KnownUser field personName to the people.get method.

The v1 API primaryEventType field roughly corresponds with the v2 primaryActionDetail.

Actions

In the v1 API, the type of activity and the data associated with that activity were in separate fields. For example, if the primaryEventType field contained the value move, then apps would assume a top-level move field would be populated with the added and removed parents.

In the v2 API, these are no longer distinct; the ActionDetail message has exactly one field set, and that field signifies the type of action and contains the details associated with that action. For example, an ActionDetail representing a Move would set only the move field, and that field would list the added and removed parents.

Targets

In the v1 API, targets were always Drive items. Sometimes, this would be misleading. For example, changes to a Team Drive in the v1 API were represented with a target of the Team Drive's root folder, which is a Drive item.

In the v2 API, targets can be other types of objects in Google Drive. For example, changes to a Team Drive have a target type of TeamDrive. The root folder of the Team Drive is still returned (as a DriveItem in the root field), but it is no longer the immediate target of the activity. A similar concept applies to a FileComment, whose parent field refers to the Drive item containing the target comment thread.

Consolidated Activity

In the v1 API, the style of response changed when a consolidation ("grouping") strategy was set. Specifically, when consolidation was enabled, each activity contained the constituent singleEvents and a combinedEvent that summarized the common activity among those constituent events. When consolidation was disabled, the combinedEvent field contained the original unconsolidated event for each activity. Any of these events could, by itself, represent more than one action, such as a create along with a share.

In the v2 API, the style of response does not change based on the consolidation strategy, as the returned DriveActivity always contains the full set of actors, targets, and actions.

Send feedback about...

Google Drive Activity API
Need help? Visit our support page.