ส่งคืนข้อมูลผู้ใช้
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Google ไดรฟ์มีตัวเลือก 2 อย่างในการรวบรวมข้อมูลเกี่ยวกับ
ผู้ใช้ไดรฟ์
เมื่อใช้แหล่งข้อมูล about
คุณจะดึงข้อมูลเกี่ยวกับผู้ใช้ การตั้งค่าไดรฟ์ของผู้ใช้ และความสามารถของระบบได้
เมื่อใช้แหล่งข้อมูล apps
คุณจะดึงข้อมูล
รายการแอปที่ผู้ใช้ติดตั้งพร้อมข้อมูลเกี่ยวกับ
ประเภท MIME, นามสกุลไฟล์ และรายละเอียดอื่นๆ ที่แอปแต่ละแอปรองรับได้
คำแนะนำนี้อธิบายวิธีดึงข้อมูลผู้ใช้ในไดรฟ์
ดูรายละเอียดเกี่ยวกับผู้ใช้
หากต้องการแสดงข้อมูลเกี่ยวกับผู้ใช้ไดรฟ์เป็นอินสแตนซ์ของ
about
ให้ใช้วิธีการ
get
ค่าที่แสดงผลจะวัดเป็นไบต์
คุณต้องตั้งค่าfields
พารามิเตอร์ระบบใน
เมธอด get
เพื่อระบุช่องที่จะแสดงผลในการตอบกลับ ในเมธอดของไดรฟ์ส่วนใหญ่ การดำเนินการนี้จำเป็นต่อการแสดงผลฟิลด์ที่ไม่ใช่ค่าเริ่มต้นเท่านั้น
แต่จำเป็นสำหรับทรัพยากร 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
: URL ของรูปโปรไฟล์ของผู้ใช้
PERMISSION_ID
: รหัสของผู้ใช้ภายในทรัพยากร Permission
EMAIL_ADDRESS
: อีเมลของผู้ใช้
แสดงรายการแอปของผู้ใช้
แอป Google ไดรฟ์จะแสดงอยู่ใน Google Workspace Marketplace และใช้เพื่อเพิ่มความสะดวกในการใช้งานไดรฟ์ เช่น แอป Google เอกสาร หรือส่วนเสริมที่ใช้ภายในเอกสารเพื่อลงนามในเอกสาร ดูข้อมูลเพิ่มเติมได้ที่ใช้แอป Google ไดรฟ์
หากต้องการแสดงรายการแอปทั้งหมดที่ผู้ใช้ติดตั้งเป็นอินสแตนซ์ของ apps
ให้ใช้วิธี list
โดยไม่มีพารามิเตอร์
หากต้องการระบุช่องที่จะแสดงผลในคำตอบ คุณสามารถตั้งค่า
fields
system
parameter ได้ หากไม่ได้ระบุพารามิเตอร์ 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
: รหัสแอป
PRODUCT_ID
: รหัสข้อมูลผลิตภัณฑ์สำหรับแอปนี้
แสดงแอปของผู้ใช้ที่มีพารามิเตอร์การค้นหา
หากต้องการค้นหาแอปที่เฉพาะเจาะจง ให้ใช้พารามิเตอร์การค้นหาที่ไม่บังคับอย่างน้อย 1 รายการต่อไปนี้
appFilterExtensions
: กรองผลการค้นหาโดยใช้รายการนามสกุลไฟล์ที่คั่นด้วยคอมมา
แอปภายในขอบเขตการค้นหาแอปที่เปิดส่วนขยายไฟล์ที่ระบุได้จะรวมอยู่ในคำตอบ หากระบุ appFilterMimeTypes
ด้วย ระบบจะแสดงผลการรวมรายการแอป 2 รายการที่ได้
ตัวอย่างส่วนขยาย ได้แก่ docx
สำหรับ Microsoft Word และ pptx
สำหรับ
Microsoft PowerPoint ดูตัวอย่างนามสกุลไฟล์เพิ่มเติมได้ที่ส่งออกประเภท MIME สำหรับเอกสาร Google Workspace
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีระบุนามสกุลไฟล์หลายรายการเป็นพารามิเตอร์การค้นหา GET
https://www.googleapis.com/drive/v3/apps?appFilterExtensions=docx,pptx
appFilterMimeTypes
: กรองผลการค้นหาโดยใช้รายการประเภท MIME ที่คั่นด้วยคอมมา
แอปภายในขอบเขตการค้นหาแอปที่เปิด MIME
types ที่ระบุได้จะรวมอยู่ในการตอบกลับ หากระบุ appFilterExtensions
ด้วย
ระบบจะแสดงผลรายการแอป 2 รายการที่รวมกัน ตัวอย่างประเภท MIME ได้แก่ application/vnd.google-apps.form
สำหรับ Google ฟอร์มและ application/vnd.google-apps.site
สำหรับ Google Sites ดูตัวอย่างเพิ่มเติมของประเภท
MIME ได้ที่ประเภท MIME ที่รองรับใน Google Workspace และ Google ไดรฟ์
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีระบุประเภท MIME หลายประเภทเป็นพารามิเตอร์การค้นหา GET
https://www.googleapis.com/drive/v3/apps?appFilterMimeTypes=application/vnd.google-apps.form,application/vnd.google-apps.site
languageCode
: กรองผลการค้นหาโดยใช้รหัสภาษาหรือรหัสภาษาและประเทศ
ตามที่กำหนดโดย BCP 47 โดยมีส่วนขยายบางส่วนจากรูปแบบ LDML ของ Unicode ตัวอย่างรหัสภาษา
ได้แก่ en-us
สำหรับภาษาอังกฤษ (สหรัฐอเมริกา) และ fr-ca
สำหรับภาษาฝรั่งเศส (แคนาดา)
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีระบุรหัสภาษาหลายรายการเป็นพารามิเตอร์การค้นหา GET
https://www.googleapis.com/drive/v3/apps?languageCode=en-us,fr-ca
รับแอปของผู้ใช้ตามรหัส
หากต้องการดาวน์โหลดข้อมูลแอปแบบละเอียดเป็นอินสแตนซ์ของ
apps
ให้ใช้เมธอด get
กับรหัสแอป
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีระบุ 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
: รหัสแอป
PRODUCT_ID
: รหัสข้อมูลผลิตภัณฑ์สำหรับแอปนี้
ขั้นตอนถัดไปที่คุณอาจลองทำมีดังนี้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-09-02 UTC
[null,null,["อัปเดตล่าสุด 2025-09-02 UTC"],[],[],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)."]]