Configure a Drive UI integration

To display your app in Google Drive when a user creates or opens a file, youmust first set up a Drive user interface (UI) integration.Configuration is also required to list your app in theGoogle Workspace Marketplace.

Enable the Drive API

Before using Google APIs, you must turn them on in a Google Cloudproject. You can turn on one or more APIs in a single Google Cloudproject.

To get started integrating with the Google Drive UI, you must enable theDrive API. This gives you access to the API and the UI integrationfeatures.

  • In the Google Cloud console, enable the Google Drive API.

    Enable the API

Set up Drive UI integration

  1. In the Google API Console, go to Menu>APIs & Services>Enabled APIs & services.

    Go to Enabled APIs & services

  2. At the bottom of the APIs & Services dashboard, clickGoogle Drive API. TheGoogle Drive API configuration page appears.
  3. Select theDrive UI integration tab.
  4. (Optional) Enter a name in theApplication name field. The applicationname is displayed to users in the Manage Apps tab in Drivesettings.
  5. (Optional) Enter a short, one-line description in theShort descriptionfield. The short description is displayed to users in the Manage Apps tab inDrive settings.
  6. (Optional) Enter a full description in theLong description field.
  7. Upload one or moreApplication icons to display in a user's list ofconnected Drive apps and in the "Open with" context menu.Icons should be in PNG format with a transparent background. Icons can takeup to 24 hours to appear in Drive.

    Note:Document icons are deprecated. Your application icon appears nextto shortcut and third-party shortcut files. A set of standard icons is usedfor other file types.
  8. To useDrive UI's "Open with" menuitem, enter the URL to your app in theOpen URL field. This URL is used by the "Open With" context menu.

    • This URL must contain a fully qualified domain name;localhost doesn'twork.
    • This URL should be accessible to the intended users of your application.If you have multiple application versions, such as one for publicrelease and one for restricted release to select users, each versionshould use a unique URL. You can then create different appconfigurations for each version.
    • You mustverify ownership of this URL before you can list your app in the Google Workspace Marketplace.
    • By default, astate query parameter is appended to this URL to passdata from the Drive UI to your app. For information onthe contents of thestate parameter, seeThestateparameter.
    Warning: The option to automatically show the OAuth 2.0 consent screen isdeprecated. Don't check this box. The application must start all authorizationrequests.
  9. (Optional) Enter default MIME types and file extensions in theDefault MIME types andDefault file extensions fields. Default MIMEtypes and file extensions represent files your app is uniquely built toopen. For example, your app might open a built-in format for layering andediting images. Only include standardmediatypes and make sure they're free of typos and misspellings. If your app only opensshortcut or third-party shortcut files, you can leave MIME type blank.

  10. (Optional) Enter secondary MIME types and file extensions in theSecondaryMIME types andSecondary file extensions fields. Secondary MIME typesand file extensions represent files your app can open, but are not specificto your app. For example, your app might be an image-editing app that opensPNG and JPG images. Only include standardmediatypes and make sure they're free of typos and misspellings. If your app only opensshortcut or third-party shortcut files, you can leave MIME type blank.

    Note: If a user installs multiple Drive apps that can open afile, the most-recently installed app is used until the user chooses anotherapp.
  11. To useDrive UI's "New"button and have users create a file withyour app, check theCreating files box. TheNew URL and optionalDocument name fields appear.

    • This URL must contain a fully qualified domain name;localhost doesn'twork.
    • You mustverify ownership of thisURL before you can list your app in the Google Workspace Marketplace.
    • By default, astate query parameter is appended to this URL to passdata from the Drive UI to your app. For information onthe contents of thestate parameter, seeThestateparameter.
  12. Enter a URL in theNew URL field. This URL is used by the "New" buttonto redirect the user to your application.

    Note: Leave the Document name field blank. This field is no longer used.
  13. (Optional) If you want your app to open Google Workspace-supported files,check theImporting box.

  14. (Optional) If your app must manage files on shared drives, check theShared drives support box. For further information on how to supportshared drives in your app, seeImplement shared drivesupport.

  15. ClickSubmit.

Request thedrive.install scope

To allow apps to appear as an option in the "Open with" or the "New" menu,request thehttps://www.googleapis.com/auth/drive.install scope to integratewith the Drive UI. When requesting this scope, users receive adialog similar to this:

Google Drive UI's installation dialog.
Figure 1. The installation dialog when using scopes for Drive UI.

For more information about scopes you can request for Drive apps,and how to request them, seeAPI-specific authorization and authenticationinformation.

Note: If youpublish your Drive appto the Google Workspace Marketplace, users and domain administrators cansearch for and install the app directly from theGoogle Workspace Marketplace.

Thestate parameter

By default, astate parameter is appended to both the Open URL and the New URLto pass data from the Drive UI to your app. This parametercontains a JSON-encoded string with template variables and data about therequest to your app. The variables included depend on the type of URL used (OpenURL or New URL):

Template variableDescriptionURL application
{ids}A comma-separated list of file IDs being opened.Open URL
{exportIds}A comma-separated list of file IDs being exported. Used only when opening Google Workspace files.Open URL
{resourceKeys}A JSON dictionary of file IDs mapped to their respective resource keys.Open URL
{folderId}The ID of the parent folder.New URL
{folderResourceKey}The resource key of the parent folder.New URL
{userId}The profile ID that identifies the user.Open URL and New URL
{action}The action being performed. The value isopen when using an Open URL orcreate when using a New URL.Open URL and New URL

Thestate parameter is URL-encoded, so your app must handle the escapecharacters and parse it as JSON. Apps can detect thecreate value in thestate parameter to verify a request to create a file.

Example state information in JSON for a New URL

Thestate information for a New URL is:

{  "action":"create",  "folderId":"FOLDER_ID",  "folderResourceKey":"FOLDER_RESOURCE_KEY",  "userId":"USER_ID"}

Example state information in JSON for an Open URL

Thestate information for an Open URL is:

{  "ids": ["ID"],  "resourceKeys":{"RESOURCE_KEYS":"RESOURCE_KEYS"},  "action":"open",  "userId":"USER_ID"}

The IDs and resource keys are used to fetch file metadata and download filecontent. Once your app has the file ID and an access token, it can checkpermissions, fetch the file metadata, and download the file content as describedin thefiles.get method.

Note: All apps, including apps opening files from shortcuts and third-partyshortcuts, should call thefiles.getmethod to check the user's permissions for a document. Apps should warnread-only users when they're opening a file they cannot edit or save (instead ofletting them spend time editing, and then displaying an error on save).

Related topics

An installed app must be able to create, manage, and open actions launched fromthe Drive UI. To learn more, seeIntegrate withDrive UI's "New" button orIntegrate with Drive UI's "Open with" contextmenu.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.