Drive UI를 사용하거나
Google Drive API를 통해 다른 사용자와 Google Drive 파일 및 폴더를 공유할 수 있습니다. 드라이브에서 공유할 때 다른 사용자가 파일을 수정하거나, 파일에 댓글을 달거나, 파일을 열 수만 있도록 설정할 수 있습니다.
리소스 키는 의도하지 않은 액세스로부터 파일을 보호하는 데 도움이 됩니다. 리소스 키는 사용자가 링크를 사용하여 공유된 특정 파일에 액세스할 수 있도록 전달되는 추가 매개변수입니다. 이전에 파일을 본 적이 없는 사용자는 액세스 권한을 얻기 위해 리소스 키를 제공해야 합니다. 최근에 파일을 보았거나 직접 액세스할 수 있는 사용자는 파일에 액세스하기 위해 리소스 키가 필요하지 않습니다.
링크로 공유된 Drive 파일은 type=user 또는 type=grouppermissions 리소스의 결과로 파일에 액세스할 수 있는 사용자만 검색할 수 있습니다. type=domain 또는 type=anyone 권한을 사용하여 이러한 링크 공유 파일에만 액세스할 수 있는 사용자의 요청에는 리소스 키가 필요할 수 있습니다.
Drive API는 files 리소스의 읽기 전용 resourceKey 필드에 파일의 리소스 키를 반환합니다.
파일이 Drive 바로가기인 경우 바로가기 타겟의 리소스 키가 읽기 전용 shortcutDetails.targetResourceKey 필드에 반환됩니다.
exportLinks, webContentLink, webViewLink과 같이 URL을 반환하는 files 리소스의 필드에도 resourceKey이 포함됩니다. Drive UI와 통합되는 클라이언트는 state 매개변수 내에서 resourceKeys를 사용할 수도 있습니다. 자세한 내용은 파일 다운로드 및 내보내기를 참고하세요.
요청에 리소스 키 설정
Drive API 요청에서 참조하는 모든 파일의 리소스 키는 X-Goog-Drive-Resource-Keys HTTP 헤더에 설정됩니다.
Drive API에 대한 요청은 X-Goog-Drive-Resource-Keys HTTP 헤더를 사용하여 하나 이상의 리소스 키를 지정할 수 있습니다.
구문
파일 ID와 리소스 키 쌍은 슬래시(/) 구분자를 사용하여 헤더에 설정됩니다. 헤더는 쉼표 (,) 구분자를 사용하여 모든 파일 ID와 리소스 키 쌍을 결합하여 빌드됩니다.
예를 들어 fileId1 파일을 fileId2 폴더에서 fileId3 폴더로 이동하라는 요청을 고려해 보겠습니다. 이 세 파일의 리소스 키가 각각 resourceKey1, resourceKey2, resourceKey3이라고 가정합니다. 슬래시와 쉼표 구분 기호를 사용하여 이러한 값으로 빌드된 헤더는 다음과 같습니다.
[[["이해하기 쉬움","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-29(UTC)"],[],[],null,["# Access link-shared Drive files using resource keys\n\nYou can share Google Drive files and folders with others using the [Drive UI](/workspace/drive/api/guides/about-apps) or through the [Google Drive API](/workspace/drive/api/guides/create-file). When you share from\nDrive, you can control whether people can edit, comment on, or\nonly open the file.\n\nA *resource key* helps protect your file from unintended access. Resource keys\nare an additional parameter that are passed so users can access certain files\nthat have been shared using a link. Users who haven't viewed the file before\nmust provide the resource key to gain access. Those who have recently viewed the\nfile, or have direct access, don't need the resource key to access the file.\n\nA Drive file that's shared with a link can only be discovered by\nusers that can access the file as a result of a `type=user` or `type=group`\n[`permissions`](/workspace/drive/api/reference/rest/v3/permissions) resource. Requests from users\nthat only have access to these link-shared files using a `type=domain` or\n`type=anyone` permission might require a resource key.\n\nFor more information about permissions, see [Share files, folders and drives](/workspace/drive/api/guides/manage-sharing). For a complete list of roles and the operations\npermitted by each, see [Roles \\& permissions](/workspace/drive/api/guides/ref-roles).\n\nRead the resource key from the file\n-----------------------------------\n\nThe Drive API returns a file's resource key on the read-only\n`resourceKey` field of the [`files`](/workspace/drive/api/reference/rest/v3/files) resource.\n\nIf the file is a [Drive shortcut](/workspace/drive/api/guides/shortcuts), the\nresource key for the shortcut target is returned on the read-only\n`shortcutDetails.targetResourceKey` field.\n\nFields in the [`files`](/workspace/drive/api/reference/rest/v3/files) resource that return URLs,\nsuch as `exportLinks`, `webContentLink`, and `webViewLink`, also include the\n`resourceKey`. Clients that integrate with the Drive UI can also\nuse `resourceKeys` within the [`state`](/workspace/drive/api/guides/enable-sdk#construct)\nparameter. For more information, see [Download and export\nfiles](/workspace/drive/api/guides/manage-downloads).\n\nSet the resource key on the request\n-----------------------------------\n\nResource keys for any files referenced by requests to the Drive API\nare set on the `X-Goog-Drive-Resource-Keys` HTTP header.\n\nRequests to the Drive API can specify one or more resource keys with\nthe `X-Goog-Drive-Resource-Keys` HTTP header.\n\n### Syntax\n\nA file ID and resource key pair are set on the header using a forward slash\n(`/`) separator. The header is built by combining all the file ID and resource\nkey pairs using comma (`,`) separators.\n\nFor example, consider a request to move file `fileId1` from folder `fileId2` to\nfolder `fileId3`. Assume the resource keys for these three files are\n`resourceKey1`, `resourceKey2`, and `resourceKey3`, respectively. The header\nbuilt from these values using a forward slash and comma separators is: \n\n X-Goog-Drive-Resource-Keys: fileId1/resourceKey1,fileId2/resourceKey2,fileId3/resourceKey3\n\n### Related topics\n\n- [Share files, folders and drives](/workspace/drive/api/guides/manage-sharing)\n- [Download and export files](/workspace/drive/api/guides/manage-downloads)\n- [Protect file content](/workspace/drive/api/guides/content-restrictions)\n- [Configure a Drive UI integration](/workspace/drive/api/guides/enable-sdk)"]]