Google 课堂插件现已面向开发者正式推出!如需了解详情,请参阅
插件文档。
Method: registrations.create
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
创建 Registration
,使 Google 课堂开始从所提供的 feed
向 cloudPubSubTopic
中提供的目标发送通知。
返回创建的 Registration
。目前,此值与参数相同,但会填充服务器分配的字段(例如 expiryTime
和 id
)。
请注意,系统会忽略为 expiryTime
或 id
字段指定的任何值。
虽然 Google 课堂可能会尽最大努力验证 cloudPubSubTopic
并返回错误,但调用方有责任确保该文件存在且 Google 课堂有权向其发布内容。
此方法可能会返回以下错误代码:
PERMISSION_DENIED
(如果):
- 已通过身份验证的用户无权接收来自请求字段的通知;或者
- 当前用户未向请求的 Feed 授予对当前 Cloud 项目的适当范围的访问权限。请注意,目前不支持出于此目的进行全网域授权。如果请求具有适当的范围,但不存在授予,则会返回 [请求错误][
@MissingGrant
错误]。
- 遇到了另一个访问权限错误。
INVALID_ARGUMENT
(如果):
- 未指定
cloudPubsubTopic
,或指定的 cloudPubsubTopic
无效;或者
- 未指定
feed
,或者指定的 feed
无效。
NOT_FOUND
(如果):
- 找不到指定的
feed
,或者请求用户无权确定其是否存在;或者
- 找不到指定的
cloudPubsubTopic
,或者 Google 课堂未获授权向其发布内容。
HTTP 请求
POST https://classroom.googleapis.com/v1/registrations
网址采用 gRPC 转码语法。
请求正文
请求正文包含一个 Registration
实例。
响应正文
如果成功,响应正文将包含一个新创建的 Registration
实例。
授权范围
需要以下 OAuth 范围:
https://www.googleapis.com/auth/classroom.push-notifications
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],[],null,["# Method: registrations.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n\nCreates a `Registration`, causing Classroom to start sending notifications from the provided `feed` to the destination provided in `cloudPubSubTopic`.\n\nReturns the created `Registration`. Currently, this will be the same as the argument, but with server-assigned fields such as `expiryTime` and `id` filled in.\n\nNote that any value specified for the `expiryTime` or `id` fields will be ignored.\n\nWhile Classroom may validate the `cloudPubSubTopic` and return errors on a best effort basis, it is the caller's responsibility to ensure that it exists and that Classroom has permission to publish to it.\n\nThis method may return the following error codes:\n\n- `PERMISSION_DENIED` if:\n - the authenticated user does not have permission to receive notifications from the requested field; or\n - the current user has not granted access to the current Cloud project with the appropriate scope for the requested feed. Note that domain-wide delegation of authority is not currently supported for this purpose. If the request has the appropriate scope, but no grant exists, a \\[Request Errors\\]\\[`@MissingGrant` error\\] is returned.\n - another [access error](/workspace/classroom/reference/Access.Errors) is encountered.\n- `INVALID_ARGUMENT` if:\n - no `cloudPubsubTopic` is specified, or the specified `cloudPubsubTopic` is not valid; or\n - no `feed` is specified, or the specified `feed` is not valid.\n- `NOT_FOUND` if:\n - the specified `feed` cannot be located, or the requesting user does not have permission to determine whether or not it exists; or\n - the specified `cloudPubsubTopic` cannot be located, or Classroom has not been granted permission to publish to it.\n\n### HTTP request\n\n`POST https://classroom.googleapis.com/v1/registrations`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Request body\n\nThe request body contains an instance of [Registration](/workspace/classroom/reference/rest/v1/registrations#Registration).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Registration](/workspace/classroom/reference/rest/v1/registrations#Registration).\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/classroom.push-notifications`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]