Google Drive menu settings

To display your app in Google Drive when a user creates or opens a file, you must first configure a Drive UI integration. Configuration is also required to list your app in the Google Workspace Marketplace.

  1. Sign in to the Google API Console.
  2. At the top of the page, next to the Google APIs logo, select your apps project. The APIs and Services dashboard appears.
  3. At the bottom of the APIs & Services dashboard, click Google Drive API. If you dont see this option, you must enable the Google Drive API.
  4. In the left-hand nav, click Drive UI Integration. The Configuration page appears.
  5. Enter an application name in the Application Name field. The application name is displayed to users in the Manage apps dialog in the Google Drive UI (gear icon > settings > Manage Apps).
  6. Enter a short description in the Short Description field. The short description is displayed to users in the Manage apps dialog in the Google Drive UI (gear icon > settings > Manage Apps).
  7. (optional) Enter a long description in the Long Description field.
  8. Upload one or more icons to display in a user's list of connected Drive apps and in the "Open with" context menu item. Icons should be in PNG format with a transparent background. Icons can ake up to 24 hours to appear in Drive.

    Note: Document icons are deprecated. Your application icon appears next to shortcut and third-party shortcut files. A set of standard icons is used for other file types.
  9. If you want to allow users to use the Drive UI's "Open with" context menu item, enter a url to your app in the Open URL field. This URL is used by the "Open With" context menu item.

    • This URL must contain a fully-qualified domain name; localhost doesn't work.
    • You must verify ownership of this URL before you can list your app in the Google Workspace Marketplace.
    • By default, a state query parameter is appended to this URL to pass data from the Drive UI to your app. For information on the contents of the state parameter, refer to The state parameter.
    Warning: Automatically showing OAuth 2.0 consent screen is deprecated. Don't select this option. All authorization requests must be initiated by the application.
  10. Enter default mime types and file extensions in the Default Mime Types and Default File Extensions fields. Default mime types and file extensions represent files that your app is uniquely built to open. For example, your app might open a native format for layering and editing images. Only include standard media types and make sure theyre free of typos and misspellings. If your app only opens shortcut or third-party shortcut files, you can leave MIME type blank.

  11. Enter secondary mime types and file extensions in the Secondary Mime Types and Secondary File Extensions fields. Secondary mime types and file extensions represent files that your app can open, but arent specific to your app. For example, your app might be an image editing app that opens png and jpg images. Only include standard media types and make sure theyre free of typos and misspellings. If your app only opens shortcut or third-party shortcut files, you can leave MIME type blank.

    Note: If a user installs multiple Drive apps that can open a file, the most-recently installed app is used until the user chooses another app.
  12. If you want users to click on the Drive UI's New button and create a new file with your app, check Allow users to create new documents using this application. The New URL and Document Name fields appear.

    • This URL must contain a fully-qualified domain name; localhost doesn't work.
    • You must verify ownership of this URL before you can list your app in the Google Workspace Marketplace.
    • By default, a state query parameter is appended to this URL to pass data from the Drive UI to your app. For information on the contents of the state parameter, refer to The state parameter.
  13. Enter a URL in the New URL field. This URL is used by the "New" button to redirect the user to your application.

    Note: Leave the Document Name field blank. This field is no longer used.
  14. (Optional) If you want your app to be able to open Google Workspace-supported files, check Importing.

  15. (Optional) If your app needs to manipulate files on shared drives, check Shared drive support. For further information on how to support shared drives in your app, refer to Implement shared drive support

  16. Click Save Changes.

Request the drive.install scope

You must request the https://www.googleapis.com/auth/drive.install scope to integrate with the Drive UI. When requesting this scope, users see a dialog similar to this:

Google Drive menu settings

For more information about scopes you can request for Drive apps, and how to request them, see What scope or scopes does my app need?

Note: If your app is published to the Google Workspace Marketplace, users and domain administrators can search for and install the app directly from the Google Workspace Marketplace.

The state parameter

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

Template variable Description Applicable to which URL type? {ids} A comma-separated list of file IDs that are being opened. Open URL {exportIds} A comma-separated list of file IDs that are being exported (used only when opening native Google documents). 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 uniquely identifies the user. Open URL and New URL {action} The action being performed. This value is open when using an Open URL or create when using a New URL. Open URL and New URL

The state parameter is URL-encoded, so your app must handle the escape characters and parse it as JSON. Apps can detect the create value in the state parameter to verify that this is a request to create a new file.

Example state information for a New URL (in JSON notation)

The state information for a New URL is:

{ "action":"create", "folderId":"0ADK06pfg", "folderResourceKey":"kahDue92has-1", "userId":"103354693083460731603" }

Example state information for an Open URL (in JSON notation)

The state information for an Open URL is:

{ "ids": ["0Bz0bd"], "resourceKeys":{"0Bz0bd":"AAshj23Ad1"}, "action":"open", "userId":"103354693083460731603" }

The IDs and resource keys are used to fetch file metadata and download file content. Once your app has the file ID and an access token, it app can check permissions, fetch the file metadata, and download the file content as described in the reference documentation for files.get.

Note: All apps, including apps opening files from shortcuts and third-party shortcuts, should call files.get to check the user's permissions for a document. Apps should warn read-only users when they are opening a file they cannot edit or save (instead of letting them spend time editing, and then giving an error on save).

Next steps

An installed app needs to be able to handle create and open actions launched from the Drive UI. See Handle a New URL or Handle a Open URL to learn more.