傳回使用者資訊
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Google 雲端硬碟提供兩種方式,可收集雲端硬碟使用者的相關資訊:
本指南說明如何在 Google 雲端硬碟中擷取使用者資訊。
取得使用者的詳細資料
如要以 about
的執行個體形式傳回雲端硬碟使用者資訊,請使用 get
方法。傳回值以位元組為單位。
您必須在 get
方法中設定 fields
system 參數,指定要在回應中傳回的欄位。在大多數雲端硬碟方法中,這項動作僅用於傳回非預設欄位,但對於 about
資源而言,這是必要動作。如果省略參數,這個方法會傳回錯誤。詳情請參閱「傳回特定欄位」。
以下程式碼範例說明如何在要求中提供多個 fields
做為查詢參數。回應會傳回要求的欄位值。
要求
GET https://www.googleapis.com/drive/v3/about/?fields=kind,user,storageQuota
回應
{
"kind": "drive#about",
"user": {
"kind": "drive#user",
"displayName": "DISPLAY_NAME",
"photoLink": "PHOTO_LINK",
"me": true,
"permissionId": "PERMISSION_ID",
"emailAddress": "EMAIL_ADDRESS"
},
"storageQuota": {
"usage": "10845031958",
"usageInDrive": "2222008387",
"usageInDriveTrash": "91566"
}
}
回應會包含下列值:
DISPLAY_NAME
:使用者的純文字名稱。
PHOTO_LINK
:使用者個人資料相片的網址。
PERMISSION_ID
:使用者在 Permission
資源中的 ID。
EMAIL_ADDRESS
:使用者的電子郵件地址
列出使用者應用程式
Google 雲端硬碟應用程式會列在 Google Workspace Marketplace 中,可讓雲端硬碟更方便使用,例如 Google 文件應用程式,或是在 Google 文件中用來簽署文件的外掛程式。詳情請參閱「使用 Google 雲端硬碟應用程式」。
如要以 apps
執行個體的形式,傳回使用者安裝的所有應用程式清單,請使用 list
方法,且不帶任何參數。
如要指定要在回應中傳回的欄位,請設定 fields
system 參數。如未指定 fields
參數,伺服器會傳回預設欄位集。詳情請參閱「傳回特定欄位」。
下列程式碼範例說明如何在要求中傳回使用者安裝的所有應用程式清單。回應會傳回要求的欄位值。
要求
GET https://www.googleapis.com/drive/v3/apps
回應
{
"kind": "drive#appList",
"selfLink": "https://www.googleapis.com/drive/v3/apps",
"items": [
{
"kind": "drive#app",
"id": "ID",
"name": "Google Sheets",
"supportsCreate": true,
"supportsImport": true,
"supportsMultiOpen": false,
"supportsOfflineCreate": true,
"productUrl": "https://chrome.google.com/webstore/detail/felcaaldnbdncclmgdcncolpebgiejap",
"productId": "PRODUCT_ID"
}
],
"defaultAppIds": [
"ID"
]
}
回應會包含下列值:
ID
:應用程式 ID。
PRODUCT_ID
:這個應用程式的產品資訊 ID。
使用查詢參數列出使用者應用程式
如要尋找特定應用程式,請使用一或多個選用查詢參數:
appFilterExtensions
:使用以半形逗號分隔的副檔名清單,篩選搜尋結果。回應中會列出應用程式查詢範圍內可開啟所列副檔名的應用程式。如果也提供 appFilterMimeTypes
,系統會傳回兩個結果應用程式清單的聯集。例如 Microsoft Word 的副檔名為 docx
,Microsoft PowerPoint 的副檔名為 pptx
。如需更多副檔名範例,請參閱「匯出 Google Workspace 文件的 MIME 類型」。
下列程式碼範例說明如何以查詢參數的形式提供多個副檔名:GET
https://www.googleapis.com/drive/v3/apps?appFilterExtensions=docx,pptx
。
appFilterMimeTypes
:使用以半形逗號分隔的 MIME 類型清單,篩選搜尋結果。回應中會列出應用程式查詢範圍內,可開啟所列 MIME 類型的應用程式。如果也提供 appFilterExtensions
,系統會傳回這兩個應用程式清單的聯集。MIME 類型範例包括 Google 表單的 application/vnd.google-apps.form
和 Google 協作平台的 application/vnd.google-apps.site
。如需更多 MIME 類型範例,請參閱「Google Workspace 和 Google 雲端硬碟支援的 MIME 類型」。
以下程式碼範例說明如何以查詢參數的形式提供多個 MIME 類型:GET
https://www.googleapis.com/drive/v3/apps?appFilterMimeTypes=application/vnd.google-apps.form,application/vnd.google-apps.site
。
languageCode
:使用 BCP 47 定義的語言或地區代碼篩選搜尋結果,並搭配 Unicode 的 LDML 格式擴充功能。語言代碼範例包括英文 (美國) 的 en-us
,以及法文 (加拿大) 的 fr-ca
。
以下程式碼範例說明如何以查詢參數的形式提供多個語言代碼:GET
https://www.googleapis.com/drive/v3/apps?languageCode=en-us,fr-ca
。
依 ID 取得使用者應用程式
如要以 apps
的執行個體形式下載詳細應用程式資訊,請使用 get
方法和應用程式 ID。
以下程式碼範例說明如何在要求中以查詢參數的形式提供 appId
。回應會傳回要求的欄位值。
要求
GET https://www.googleapis.com/drive/v3/apps/APP_ID
回應
{
"kind": "drive#app",
"id": "ID",
"name": "Google Sheets",
"supportsCreate": true,
"supportsImport": true,
"supportsMultiOpen": false,
"supportsOfflineCreate": true,
"productUrl": "https://chrome.google.com/webstore/detail/felcaaldnbdncclmgdcncolpebgiejap",
"productId": "PRODUCT_ID"
}
回應會包含下列值:
ID
:應用程式 ID。
PRODUCT_ID
:這個應用程式的產品資訊 ID。
建議您採取下列後續步驟:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-02 (世界標準時間)。
[null,null,["上次更新時間:2025-09-02 (世界標準時間)。"],[],[],null,["Google Drive provides two options to gather information about\nDrive users:\n\n- Using the [`about`](/workspace/drive/api/reference/rest/v3/about) resource, you can retrieve\n information about the user, the user's Drive settings, and\n their system capabilities.\n\n- Using the [`apps`](/workspace/drive/api/reference/rest/v3/apps) resource, you can retrieve a\n list of the user's installed apps, with information about each app's\n supported MIME types, file extensions, and other details.\n\nThis guide explains how you can retrieve user info in Drive.\n\nGet details about a user\n\nTo return information on a Drive user as an instance of\n[`about`](/workspace/drive/api/reference/rest/v3/about), use the\n[`get`](/workspace/drive/api/reference/rest/v3/about/get) method. The returned values are measured\nin bytes.\n\nYou *must* set the `fields` [system\nparameter](https://cloud.google.com/apis/docs/system-parameters#definitions) on\nthe `get` method to specify the fields to return in the response. In most\nDrive methods this action is only required to return non-default\nfields but it's mandatory for the `about` resource. If you omit the parameter,\nthe method returns an error. For more information, see [Return specific fields](/workspace/drive/api/guides/fields-parameter).\n| **Note:** If you're using the previous Drive API v2 version, setting the `fields` parameter in the `get` method isn't required. Learn how to [migrate to\nDrive API v3](/workspace/drive/api/guides/migrate-to-v3). \nThe following code sample shows how to provide multiple `fields` as a query parameter in the request. The response returns the field values for the request.\n\n**Request** \n\n```text\nGET https://www.googleapis.com/drive/v3/about/?fields=kind,user,storageQuota\n```\n\n**Response** \n\n```scdoc\n{\n \"kind\": \"drive#about\",\n \"user\": {\n \"kind\": \"drive#user\",\n \"displayName\": \"DISPLAY_NAME\",\n \"photoLink\": \"PHOTO_LINK\",\n \"me\": true,\n \"permissionId\": \"PERMISSION_ID\",\n \"emailAddress\": \"EMAIL_ADDRESS\"\n },\n \"storageQuota\": {\n \"usage\": \"10845031958\",\n \"usageInDrive\": \"2222008387\",\n \"usageInDriveTrash\": \"91566\"\n }\n}\n```\n\nThe response includes the following values:\n\n- \u003cvar translate=\"no\"\u003eDISPLAY_NAME\u003c/var\u003e: the user's name in plain text.\n- \u003cvar translate=\"no\"\u003ePHOTO_LINK\u003c/var\u003e: the URL of the user's profile photo.\n- \u003cvar translate=\"no\"\u003ePERMISSION_ID\u003c/var\u003e: the user's ID within the `Permission` resources.\n- \u003cvar translate=\"no\"\u003eEMAIL_ADDRESS\u003c/var\u003e: the user's email address\n\nList user apps\n\nGoogle Drive apps are listed in the\n[Google Workspace Marketplace](https://workspace.google.com/marketplace) and\nare used to make Drive more convenient such as the Google Docs\napp or an add-on used within Docs to\nsign documents. For more information, see [Use Google Drive\napps](https://support.google.com/drive/answer/2500820).\n\nTo return a list of all the user's installed apps as an instance of [`apps`](/workspace/drive/api/reference/rest/v3/apps), use the [`list`](/workspace/drive/api/reference/rest/v3/apps/list) method\nwithout any parameters.\n\nIf you want to specify the fields to return in the response, you can set the\n`fields` [system\nparameter](https://cloud.google.com/apis/docs/system-parameters#definitions). If\nyou don't specify the `fields` parameter, the server returns a default set of\nfields. For more information, see [Return specific fields](/workspace/drive/api/guides/fields-parameter).\n| **Note:** If you're using the previous Drive API v2 version, the response body also includes the `etag` field. Learn how to [migrate to\nDrive API v3](/workspace/drive/api/guides/migrate-to-v3). \nThe following code sample shows how to return a list of all the user's installed apps in the request. The response returns the field values for the request.\n\n**Request** \n\n```text\nGET https://www.googleapis.com/drive/v3/apps\n```\n\n**Response** \n\n```scdoc\n{\n \"kind\": \"drive#appList\",\n \"selfLink\": \"https://www.googleapis.com/drive/v3/apps\",\n \"items\": [\n {\n \"kind\": \"drive#app\",\n \"id\": \"ID\",\n \"name\": \"Google Sheets\",\n \"supportsCreate\": true,\n \"supportsImport\": true,\n \"supportsMultiOpen\": false,\n \"supportsOfflineCreate\": true,\n \"productUrl\": \"https://chrome.google.com/webstore/detail/felcaaldnbdncclmgdcncolpebgiejap\",\n \"productId\": \"PRODUCT_ID\"\n }\n ],\n \"defaultAppIds\": [\n \"ID\"\n ]\n}\n```\n\nThe response includes the following values:\n\n- \u003cvar translate=\"no\"\u003eID\u003c/var\u003e: the app ID.\n- \u003cvar translate=\"no\"\u003ePRODUCT_ID\u003c/var\u003e: the product listing ID for this app.\n\nList user apps with query parameters\n\nTo find a specific app, use one or more of the optional query parameters:\n\n- `appFilterExtensions`: Filter the search results using a comma-separated\n list of file extensions. Apps within the app query scope that can open the\n listed file extensions are included in the response. If `appFilterMimeTypes`\n are also provided, a union of the two resulting app lists is returned.\n Examples of extensions include `docx` for Microsoft Word and `pptx` for\n Microsoft PowerPoint. For more examples of file extensions, see [Export MIME\n types for Google Workspace documents](/workspace/drive/api/guides/ref-export-formats).\n\n The following code sample shows how to provide multiple file extensions as a\n query parameter: `GET\n https://www.googleapis.com/drive/v3/apps?appFilterExtensions=docx,pptx`.\n- `appFilterMimeTypes`: Filter the search results using a comma-separated list\n of MIME types. Apps within the app query scope that can open the listed MIME\n types are included in the response. If `appFilterExtensions` are also\n provided, a union of the two resulting app lists is returned. Examples of\n MIME types include `application/vnd.google-apps.form` for Google Forms and\n `application/vnd.google-apps.site` for Google Sites. For more examples of\n MIME types, see [Google Workspace and Google Drive supported MIME\n types](/workspace/drive/api/guides/mime-types).\n\n The following code sample shows how to provide multiple MIME types as a\n query parameter: `GET\n https://www.googleapis.com/drive/v3/apps?appFilterMimeTypes=application/vnd.google-apps.form,application/vnd.google-apps.site`.\n- `languageCode`: Filter the search results using a language or locale code,\n as defined by BCP 47, with some extensions from [Unicode's LDML\n format](https://www.unicode.org/reports/tr35/). Examples of language codes\n include `en-us` for English (United States) and `fr-ca` for French (Canada).\n\n The following code sample shows how to provide multiple language codes as a\n query parameter: `GET\n https://www.googleapis.com/drive/v3/apps?languageCode=en-us,fr-ca`.\n\nGet user app by ID\n\nTo download the detailed app info as an instance of\n[`apps`](/workspace/drive/api/reference/rest/v3/apps), use the [`get`](/workspace/drive/api/reference/rest/v3/apps/get)\nmethod with the app ID. \nThe following code sample shows how to provide an `appId` as a query parameter in the request. The response returns the field values for the request.\n\n**Request** \n\n```scdoc\nGET https://www.googleapis.com/drive/v3/apps/APP_ID\n```\n\n**Response** \n\n```scdoc\n{\n \"kind\": \"drive#app\",\n \"id\": \"ID\",\n \"name\": \"Google Sheets\",\n \"supportsCreate\": true,\n \"supportsImport\": true,\n \"supportsMultiOpen\": false,\n \"supportsOfflineCreate\": true,\n \"productUrl\": \"https://chrome.google.com/webstore/detail/felcaaldnbdncclmgdcncolpebgiejap\",\n \"productId\": \"PRODUCT_ID\"\n}\n```\n\nThe response includes the following values:\n\n- \u003cvar translate=\"no\"\u003eID\u003c/var\u003e: the app ID.\n- \u003cvar translate=\"no\"\u003ePRODUCT_ID\u003c/var\u003e: the product listing ID for this app.\n\nRelated topics\n\nHere are a few next steps you might try:\n\n- To create a file in Drive, see [Create and manage files](/workspace/drive/api/guides/create-file).\n\n- To upload file data when you create or update a file, see [Upload file\n data](/workspace/drive/api/guides/manage-uploads).\n\n- To download and export files, see [Download and export\n files](/workspace/drive/api/guides/manage-downloads)."]]