Drive UI의 '새로 만들기' 버튼과 통합
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
사용자가 Drive UI의 '새로 만들기' 버튼을 클릭하고 Drive UI에서 앱을 선택하면 Drive는 사용자를 Drive UI 통합 구성에 정의된 해당 앱의 새 URL로 리디렉션합니다.
그러면 앱이 state
매개변수 내에서 기본 템플릿 변수 집합을 수신합니다. 새 URL의 기본 state
정보는 다음과 같습니다.
{
"action":"create",
"folderId":"FOLDER_ID",
"folderResourceKey":"FOLDER_RESOURCE_KEY",
"userId":"USER_ID"
}
이 출력에는 다음 값이 포함됩니다.
create
: 수행 중인 작업입니다. 사용자가 Drive UI의 '새로 만들기' 버튼을 클릭하면 값은 create
입니다.
- FOLDER_ID: 상위 폴더의 ID입니다.
- FOLDER_RESOURCE_KEY: 상위 폴더의 리소스 키입니다.
- USER_ID: 사용자를 고유하게 식별하는 프로필 ID입니다.
앱은 다음 단계에 따라 이 요청에 응답해야 합니다.
action
필드의 값이 create
인지 확인합니다.
userId
값을 사용하여 사용자의 새 세션을 만듭니다. 로그인한 사용자에 대한 자세한 내용은 사용자 및 새 이벤트를 참고하세요.
files.create
메서드를 사용하여 파일 리소스를 만듭니다. 요청에 folderId
가 설정된 경우 parents
필드를 folderId
값으로 설정합니다.
- 요청에
folderResourceKey
가 설정된 경우 X-Goog-Drive-Resource-Keys
요청 헤더를 설정합니다. 리소스 키에 관한 자세한 내용은 리소스 키를 사용하여 링크 공유 파일에 액세스하기를 참고하세요.
state
매개변수는 URL로 인코딩되므로 앱에서 이스케이프 문자를 처리하고 JSON으로 파싱해야 합니다.
사용자 및 새 이벤트
Drive 앱은 모든 '생성' 이벤트를 잠재적인 로그인으로 취급해야 합니다. 일부 사용자에게는 계정이 여러 개 있을 수 있으므로 state
매개변수의 사용자 ID가 현재 세션과 일치하지 않을 수 있습니다. state
매개변수의 사용자 ID가 현재 세션과 일치하지 않으면 앱의 현재 세션을 종료하고 요청된 사용자로 로그인합니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-04(UTC)
[null,null,["최종 업데이트: 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."]]