Integrate with Drive UI's "New" button

When a user clicks Drive UI's "New" button and selects an app in the Drive UI, Drive redirects the user to that app's New URL defined in Configure a Drive UI integration.

Your app then receives a default set of template variables within a state parameter. The default state information for a New URL is:


This output includes the following values:

  • create: The action being performed. The value is create when a user clicks Drive UI's "New" button.
  • FOLDER_ID: The ID of the parent folder.
  • FOLDER_RESOURCE_KEY: The resource key of the parent folder.
  • USER_ID: The profile ID that uniquely identifies the user.

Your app must act on this request by following these steps:

  1. Verify that the action field has a value of create.
  2. Use the userId value to create a new session for the user. For more information on signed-in users, see Users & new events.
  3. Use the files.create method to create a file resource. If folderId was set on the request, set the parents field to the folderId value.
  4. If folderResourceKey was set on the request, set the X-Goog-Drive-Resource-Keys request header. For more information on resource keys, see Access link-shared files using resource keys.

The state parameter is URL-encoded, so your app must handle the escape characters and parse it as JSON.

Users & new events

Drive apps should treat all "create" events as potential sign-ins. Some users might have multiple accounts, so the user ID in the state parameter might not match the current session. If the user ID in the state parameter doesn't match the current session, end the current session for your app and sign in as the requested user.