ส่วนเสริมของ Google Classroom พร้อมให้บริการแก่นักพัฒนาซอฟต์แวร์แล้ว โปรดดูข้อมูลเพิ่มเติมใน
เอกสารส่วนเสริม
Method: courses.courseWork.getAddOnContext
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
รับข้อมูลเมตาสำหรับส่วนเสริมของ Classroom ในบริบทของโพสต์ที่เฉพาะเจาะจง
เพื่อช่วยรักษาความสมบูรณ์ของข้อมูลและรูปแบบสิทธิ์ของตนเอง ส่วนเสริมควรเรียกใช้ฟังก์ชันนี้เพื่อตรวจสอบพารามิเตอร์การค้นหาและบทบาทของผู้ใช้ที่ขอทุกครั้งที่เปิดส่วนเสริมใน iframe
วิธีการนี้จะแสดงรหัสข้อผิดพลาดต่อไปนี้
PERMISSION_DENIED
สำหรับข้อผิดพลาดในการเข้าถึง
INVALID_ARGUMENT
หากคำขอมีรูปแบบไม่ถูกต้อง
NOT_FOUND
หากทรัพยากรที่ระบุไม่อยู่
คำขอ HTTP
GET https://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{itemId}/addOnContext
URL ใช้ไวยากรณ์การแปลง gRPC
พารามิเตอร์เส้นทาง
พารามิเตอร์ |
courseId |
string
ต้องระบุ ตัวระบุของหลักสูตร
|
itemId |
string
ตัวระบุของ Announcement , CourseWork หรือ CourseWorkMaterial ที่แนบไฟล์แนบ คุณต้องกรอกข้อมูลในช่องนี้ แต่ไม่ได้ระบุว่าเป็นช่องที่ต้องกรอกขณะที่เราย้ายข้อมูลจาก postId
|
พารามิเตอร์การค้นหา
พารามิเตอร์ |
postId (deprecated) |
string
ไม่บังคับ เลิกใช้งานแล้ว โปรดใช้ itemId แทน
|
addOnToken |
string
ไม่บังคับ โทเค็นที่ให้สิทธิ์คําขอ ระบบจะส่งโทเค็นเป็นพารามิเตอร์การค้นหาเมื่อระบบเปลี่ยนเส้นทางผู้ใช้จาก Classroom ไปยัง URL ของส่วนเสริม ต้องมีโทเค็นการให้สิทธิ์เมื่อข้อใดข้อหนึ่งต่อไปนี้ไม่เป็นจริง
- ส่วนเสริมมีไฟล์แนบในโพสต์
- โปรเจ็กต์ของนักพัฒนาแอปที่ส่งคำขอคือโปรเจ็กต์เดียวกับที่สร้างโพสต์
|
attachmentId |
string
ไม่บังคับ ตัวระบุของไฟล์แนบ ฟิลด์นี้จำเป็นต้องใช้สำหรับคำขอทั้งหมด ยกเว้นในกรณีที่ผู้ใช้อยู่ใน iframe การตรวจหาไฟล์แนบ
|
เนื้อความของคำขอ
เนื้อหาของคำขอต้องว่างเปล่า
เนื้อหาการตอบกลับ
หากทำสำเร็จ เนื้อหาการตอบกลับจะมีอินสแตนซ์ AddOnContext
ขอบเขตการให้สิทธิ์
ต้องใช้ขอบเขต OAuth ต่อไปนี้
https://www.googleapis.com/auth/classroom.addons.student
https://www.googleapis.com/auth/classroom.addons.teacher
ดูข้อมูลเพิ่มเติมได้ที่คู่มือการให้สิทธิ์
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[],[],null,["# Method: courses.courseWork.getAddOnContext\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n\nGets metadata for Classroom add-ons in the context of a specific post.\n\nTo maintain the integrity of its own data and permissions model, an add-on should call this to validate query parameters and the requesting user's role whenever the add-on is opened in an [iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/iframes-overview).\n\nThis method returns the following error codes:\n\n- `PERMISSION_DENIED` for [access errors](/workspace/classroom/reference/Access.Errors).\n- `INVALID_ARGUMENT` if the request is malformed.\n- `NOT_FOUND` if one of the identified resources does not exist.\n\n### HTTP request\n\n`GET https://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{itemId}/addOnContext`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `courseId` | `string` Required. Identifier of the course. |\n| `itemId` | `string` Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from postId. |\n\n### Query parameters\n\n| Parameters ||\n|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `postId` **(deprecated)** | `string` Optional. Deprecated, use `itemId` instead. |\n| `addOnToken` | `string` Optional. Token that authorizes the request. The token is passed as a query parameter when the user is redirected from Classroom to the add-on's URL. The authorization token is required when neither of the following is true: - The add-on has attachments on the post. - The developer project issuing the request is the same project that created the post. |\n| `attachmentId` | `string` Optional. The identifier of the attachment. This field is required for all requests except when the user is in the [Attachment Discovery iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/attachment-discovery-iframe). |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nIf successful, the response body contains an instance of [AddOnContext](/workspace/classroom/reference/rest/v1/AddOnContext).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/classroom.addons.student`\n- `\n https://www.googleapis.com/auth/classroom.addons.teacher`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]