Google 课堂插件现已面向开发者正式推出!如需了解详情,请参阅
插件文档。
Method: userProfiles.guardianInvitations.create
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
创建监护人邀请,并向监护人发送电子邮件,要求他们确认自己是学生的监护人。
监护人接受邀请后,其 state
将更改为 COMPLETED
,并且会开始收到监护人通知。系统还会创建一个 Guardian
资源来代表活跃的守护者。
请求对象必须设置 studentId
和 invitedEmailAddress
字段。如果未设置这些字段,或者在请求中设置了任何其他字段,都将导致错误。
此方法会返回以下错误代码:
PERMISSION_DENIED
:如果当前用户无权管理监护人,如果相关监护人已拒绝过该学生的过多请求,如果相关网域未启用监护人,或者存在其他访问权限错误。
- 如果学生或家长已超出家长关联数量上限,则返回
RESOURCE_EXHAUSTED
。
- 如果监护人电子邮件地址无效(例如,太长),或者无法识别所提供学生证件格式(既不是电子邮件地址,也不是此 API 中的
userId
),则返回 INVALID_ARGUMENT
。如果设置了只读字段,或者将 state
字段设置为 PENDING
以外的值,系统也会返回此错误。
- 如果提供的学生 ID 是有效的学生 ID,但 Google 课堂中没有该学生的记录,则使用
NOT_FOUND
。
ALREADY_EXISTS
,如果系统已为学生发出监护人邀请,且所提供的 invitedEmailAddress
与此用户现有 Guardian
的 Google 账号匹配,则会出现此错误。invitedEmailAddress
HTTP 请求
POST https://classroom.googleapis.com/v1/userProfiles/{guardianInvitation.studentId}/guardianInvitations
网址采用 gRPC 转码语法。
路径参数
参数 |
guardianInvitation.studentId |
string
学生的 ID(采用标准格式)
|
请求正文
请求正文包含一个 GuardianInvitation
实例。
响应正文
如果成功,响应正文将包含一个新创建的 GuardianInvitation
实例。
授权范围
需要以下 OAuth 范围:
https://www.googleapis.com/auth/classroom.guardianlinks.students
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],[],null,["# Method: userProfiles.guardianInvitations.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nCreates a guardian invitation, and sends an email to the guardian asking them to confirm that they are the student's guardian.\n\nOnce the guardian accepts the invitation, their `state` will change to `COMPLETED` and they will start receiving guardian notifications. A `Guardian` resource will also be created to represent the active guardian.\n\nThe request object must have the `studentId` and `invitedEmailAddress` fields set. Failing to set these fields, or setting any other fields in the request, will result in an error.\n\nThis method returns the following error codes:\n\n- `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if the guardian in question has already rejected too many requests for that student, if guardians are not enabled for the domain in question, or for other [access errors](/workspace/classroom/reference/Access.Errors).\n- `RESOURCE_EXHAUSTED` if the student or guardian has exceeded the guardian link limit.\n- `INVALID_ARGUMENT` if the guardian email address is not valid (for example, if it is too long), or if the format of the student ID provided cannot be recognized (it is not an email address, nor a `userId` from this API). This error will also be returned if read-only fields are set, or if the `state` field is set to to a value other than `PENDING`.\n- `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student.\n- `ALREADY_EXISTS` if there is already a pending guardian invitation for the student and `invitedEmailAddress` provided, or if the provided `invitedEmailAddress` matches the Google account of an existing `Guardian` for this user.\n\n### HTTP request\n\n`POST https://classroom.googleapis.com/v1/userProfiles/{guardianInvitation.studentId}/guardianInvitations`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|--------------------------------|-------------------------------------------------|\n| `guardianInvitation.studentId` | `string` ID of the student (in standard format) |\n\n### Request body\n\nThe request body contains an instance of [GuardianInvitation](/workspace/classroom/reference/rest/v1/userProfiles.guardianInvitations#GuardianInvitation).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [GuardianInvitation](/workspace/classroom/reference/rest/v1/userProfiles.guardianInvitations#GuardianInvitation).\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/classroom.guardianlinks.students`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]