Introduction: Develop apps using the Data Portability API

The Data Portability API lets you build applications that request authorization from a user to move a copy of data from Google services into your application. This enables data portability and facilitates switching services.

If you are looking for information on how users share data, see Share a copy of your data with a third party.

Prerequisites

Before releasing your app, it must be approved by Google.

You should also verify that the Data Portability API is available to users in your location. For a list of supported countries and regions, see Common Questions on the "Share a copy of your data with a third party" page.

Developer workflow

These are the steps you follow to create an application that uses the Data Portability API.

The steps a developer follows to create an app using the Data Portability API

  1. Implement the OAuth consent flow for the user. In this example, the user is providing access to YouTube video data.

    1. The user clicks Import YouTube Videos and signs into their Google Account.

    2. The app forwards the user to an OAuth consent URL. Note that this example URL is simplified and is missing some parameters:

      https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/dataportability.myactivity.youtube

    3. The user clicks Next on the OAuth consent screen, agrees to share their data, and provides account access.

    4. The user is redirected to the app.

    5. The developer obtains an OAuth token for the user.

  2. Your app calls InitiatePortabilityArchive(resources = ["myactivity.youtube"]) with an attached OAuth token that contains this OAuth scope:

    https://www.googleapis.com/auth/dataportability.myactivity.youtube

    This call starts the process of creating the data archive. You should initiate the portability archive within 24 hours of user authorization.

  3. Your app calls GetPortabilityArchiveState(job_id) with an attached OAuth token that contains this OAuth scope:

    https://www.googleapis.com/auth/dataportability.myactivity.youtube

    You can call this method multiple times to retrieve the status of the archive job. The method returns the job's state. If the state is COMPLETE, the archive is ready, and signed Cloud Storage URLs are provided. Note that the time it takes to complete the archive request can vary from minutes to hours depending on the size of the data.

  4. Download the data archive using the signed URLs.

  5. Call ResetAuthorization() with an attached OAuth token to reset exhausted resources and to remove all OAuth consents.

For more information on using the Data Portability API methods, see Call Data Portability API methods.

How users interact with a Data Portability API app

This diagram shows how users interact with an app that's integrated with the Data Portability API.

The steps a user takes to export their data

  1. First, the user is presented with an option to retrieve their data.

  2. Next, the user signs into their Google Account.

  3. Then, the user clicks Next when they're prompted to share their data, and they click Got it when they're prompted to accept the privacy policy.

  4. Then, the user is shown an OAuth consent screen that is used to allow the application to access their data. The options here match the OAuth scopes you configured.

  5. After allowing access, the data import starts. Depending on the size of the data, the request can take several minutes to several hours to complete.