When a user clicks the "New" button and selects an app in the Drive UI, Drive redirects the user to that app's New URL defined when you Configure a Drive integration.
As mentioned in Configure a Drive UI integration, your app receives a default
set of template variables within a state
parameter. The default state
information for a New URL is:
{
"action":"create",
"folderId":"0ADK06pfg",
"folderResourceKey":"dhsEAn1",
"userId":"103354693083460731603"
}
To handle this information:
Detect the
create
value in thestate
parameter to verify that this is a request to create a new file.Use the
files.create
method to create the file using thefolderId
anduserId
values.
The state
parameter is URL-encoded, so your app must handle the escape
characters and parse it as JSON.
Handle Create New events
Drive apps should treat all "Create new" events as potential logins. Some users
may 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 log in as
the requested user.