Method: courses.courseWork.getAddOnContext
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
הצגת המטא-נתונים של תוספים ל-Classroom בהקשר של פוסט ספציפי.
כדי לשמור על תקינות מודל הנתונים וההרשאות שלו, התוסף צריך לבצע קריאה ל-method הזה כדי לאמת את פרמטרי השאילתה ואת התפקיד של המשתמש המבקש בכל פעם שהתוסף נפתח ב-iframe.
השיטה הזו מחזירה את קודי השגיאה הבאים:
PERMISSION_DENIED
עבור שגיאות גישה.
INVALID_ARGUMENT
אם הבקשה לא תקינה.
NOT_FOUND
אם אחד מהמשאבים שזוהו לא קיים.
בקשת HTTP
GET https://classroom.googleapis.com/v1/courses/{courseId}/courseWork/{itemId}/addOnContext
כתובת ה-URL משתמשת בתחביר של Transcoding של gRPC.
פרמטרים של נתיב
פרמטרים |
courseId |
string
חובה. המזהה של הקורס.
|
itemId |
string
המזהה של Announcement , CourseWork או CourseWorkMaterial שבאמצעותו מצורף הקובץ. השדה הזה הוא חובה, אבל הוא לא מסומן ככזה בזמן ההעברה מ-postId.
|
פרמטרים של שאילתה
פרמטרים |
postId (deprecated) |
string
אופציונלי. האפשרות הזו הוצאה משימוש. במקום זאת, צריך להשתמש ב-itemId .
|
addOnToken |
string
אופציונלי. אסימון שמאשר את הבקשה. האסימון מועבר כפרמטר של שאילתה כשהמשתמש מופנה מ-Classroom לכתובת ה-URL של התוסף. צריך להשתמש בטוקן ההרשאה אם אף אחד מהמצבים הבאים לא מתקיים:
- התוסף כולל קבצים מצורפים בפוסט.
- פרויקט המפתח שממנו נשלחת הבקשה הוא אותו פרויקט שבו נוצר הפוסט.
|
attachmentId |
string
אופציונלי. המזהה של הקובץ המצורף. השדה הזה נדרש בכל הבקשות, מלבד כשהמשתמש נמצא ב-iframe של Attachment Discovery.
|
גוף הבקשה
גוף הבקשה חייב להיות ריק.
גוף התשובה
אם הפעולה מצליחה, גוף התגובה מכיל מופע של AddOnContext
.
היקפי הרשאה
נדרש אחד מהיקפי ההרשאות הבאים של OAuth:
https://www.googleapis.com/auth/classroom.addons.student
https://www.googleapis.com/auth/classroom.addons.teacher
מידע נוסף זמין במדריך ההרשאות.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 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)."]]