Dodatki do Google Classroom są teraz ogólnie dostępne dla programistów. Więcej informacji znajdziesz w
dokumentacji dodatków.
Method: registrations.create
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Tworzy Registration
, co powoduje, że Classroom zacznie wysyłać powiadomienia z podanego feed
do miejsca docelowego podanego w cloudPubSubTopic
.
Zwraca utworzony Registration
. Obecnie będzie to takie samo pole, co argument, ale z wypełnionymi polami przypisanymi przez serwer, takimi jak expiryTime
i id
.
Pamiętaj, że wszystkie wartości określone w polach expiryTime
lub id
zostaną zignorowane.
Chociaż Classroom może weryfikować cloudPubSubTopic
i zwracać błędy w ramach dostępnych możliwości, to na dzwoniącym spoczywa odpowiedzialność za to, aby plik istniał i Classroom miał do niego uprawnienia do publikowania.
Ta metoda może zwrócić te kody błędów:
PERMISSION_DENIED
jeśli:
- uwierzytelniony użytkownik nie ma uprawnień do otrzymywania powiadomień z wybranego pola;
- bieżący użytkownik nie przyznał dostępu do bieżącego projektu Cloud w odpowiednim zakresie dla żądanego pliku danych. Pamiętaj, że delegowanie uprawnień w całej domenie nie jest obecnie obsługiwane w tym celu. Jeśli żądanie ma odpowiedni zakres, ale nie ma uprawnień, zwracany jest błąd [Request Errors][
@MissingGrant
error].
- wystąpił inny błąd dostępu.
INVALID_ARGUMENT
jeśli:
- nie określono właściwości
cloudPubsubTopic
lub określona wartość cloudPubsubTopic
jest nieprawidłowa;
- nie określono właściwości
feed
lub określona wartość feed
jest nieprawidłowa.
NOT_FOUND
jeśli:
- nie można znaleźć określonego
feed
lub użytkownik nie ma uprawnień do sprawdzenia, czy istnieje;
- nie można znaleźć określonego
cloudPubsubTopic
lub usługa Classroom nie ma uprawnień do publikowania w nim treści.
Żądanie HTTP
POST https://classroom.googleapis.com/v1/registrations
Adres URL używa składni transkodowania gRPC.
Treść żądania
Treść żądania zawiera wystąpienie elementu Registration
.
Treść odpowiedzi
Jeśli operacja się powiedzie, treść odpowiedzi będzie zawierała nowo utworzoną instancję Registration
.
Zakresy autoryzacji
Wymaga następującego zakresu OAuth:
https://www.googleapis.com/auth/classroom.push-notifications
Więcej informacji znajdziesz w przewodniku dotyczącym autoryzacji.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-25 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-25 UTC."],[],[],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)."]]