userId 값을 사용하여 사용자의 새 세션을 만듭니다. 로그인한 사용자에 대한 자세한 내용은 사용자 및 새 이벤트를 참고하세요.
files.create 메서드를 사용하여 파일 리소스를 만듭니다. 요청에 folderId가 설정된 경우 parents 필드를 folderId 값으로 설정합니다.
요청에 folderResourceKey가 설정된 경우 X-Goog-Drive-Resource-Keys 요청 헤더를 설정합니다. 리소스 키에 관한 자세한 내용은 리소스 키를 사용하여 링크 공유 파일에 액세스하기를 참고하세요.
state 매개변수는 URL로 인코딩되므로 앱에서 이스케이프 문자를 처리하고 JSON으로 파싱해야 합니다.
사용자 및 새 이벤트
Drive 앱은 모든 '생성' 이벤트를 잠재적인 로그인으로 취급해야 합니다. 일부 사용자에게는 계정이 여러 개 있을 수 있으므로 state 매개변수의 사용자 ID가 현재 세션과 일치하지 않을 수 있습니다. state 매개변수의 사용자 ID가 현재 세션과 일치하지 않으면 앱의 현재 세션을 종료하고 요청된 사용자로 로그인합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-04(UTC)"],[],[],null,["# Integrate with Drive UI's "New" button\n\nWhen a user clicks [Drive UI's \"New\"\nbutton](/workspace/drive/api/guides/about-apps#new) and selects an app in the\nDrive UI, Drive redirects the user to that app's New URL\ndefined in [Configure a Drive UI\nintegration](/workspace/drive/api/guides/enable-sdk).\n\nYour app then receives a default set of template variables within a\n[`state`](/workspace/drive/api/guides/enable-sdk#construct) parameter. The default `state`\ninformation for a New URL is: \n\n {\n \"action\":\"create\",\n \"folderId\":\"\u003cvar translate=\"no\"\u003eFOLDER_ID\u003c/var\u003e\",\n \"folderResourceKey\":\"\u003cvar translate=\"no\"\u003eFOLDER_RESOURCE_KEY\u003c/var\u003e\",\n \"userId\":\"\u003cvar translate=\"no\"\u003eUSER_ID\u003c/var\u003e\"\n }\n\nThis output includes the following values:\n\n- `create`: The action being performed. The value is `create` when a user clicks [Drive UI's \"New\"\n button](/workspace/drive/api/guides/about-apps#new).\n- \u003cvar translate=\"no\"\u003eFOLDER_ID\u003c/var\u003e: The ID of the parent folder.\n- \u003cvar translate=\"no\"\u003eFOLDER_RESOURCE_KEY\u003c/var\u003e: The resource key of the parent folder.\n- \u003cvar translate=\"no\"\u003eUSER_ID\u003c/var\u003e: The profile ID that uniquely identifies the user.\n\nYour app must act on this request by following these steps:\n\n1. Verify that the `action` field has a value of `create`.\n2. Use the `userId` value to create a new session for the user. For more information on signed-in users, see [Users \\& new events](#potential-logins).\n3. Use the [`files.create`](/workspace/drive/api/v3/reference/files/create) method to create a file resource. If `folderId` was set on the request, set the `parents` field to the `folderId` value.\n4. 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\n keys](/workspace/drive/api/guides/resource-keys).\n\nThe `state` parameter is URL-encoded, so your app must handle the escape\ncharacters and parse it as JSON.\n\nUsers \\& new events\n-------------------\n\nDrive apps should treat all \"create\" events as potential\nsign-ins. Some users might have multiple accounts, so the user ID in the `state`\nparameter might not match the current session. If the user ID in the `state`\nparameter doesn't match the current session, end the current session for your\napp and sign in as the requested user."]]