import{createClientWithUserCredentials}from'./authentication-utils.js';// Authorization scopes based on the event typesconstUSER_AUTH_OAUTH_SCOPES=['https://www.googleapis.com/auth/chat.memberships.readonly','https://www.googleapis.com/auth/chat.messages.readonly'];// This sample shows how to list space events with user credentialasyncfunctionmain(){// Create a clientconstchatClient=awaitcreateClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);// Initialize request argument(s)constrequest={// Replace SPACE_NAME hereparent:'spaces/SPACE_NAME',// A required filter. Filters events about new memberships and messagesfilter:'eventTypes:"google.workspace.chat.membership.v1.created" OR eventTypes:"google.workspace.chat.message.v1.created"'};// Make the requestconstpageResult=chatClient.listSpaceEventsAsync(request);// Handle the response. Iterating over pageResult will yield results and// resolve additional pages automatically.forawait(constresponseofpageResult){console.log(response);}}main().catch(console.error);
如需运行此示例,请将 SPACE_NAME 替换为聊天室的 name 中的 ID。您可以通过调用 ListSpaces() 方法或从聊天室的网址中获取此 ID。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-02-14。"],[[["This guide explains how to use the `list()` method to list changes to resources in a Google Chat space using the `SpaceEvent` resource."],["You can list events up to 28 days prior, retrieving the most recent version of affected resources, and must authenticate with user credentials and be a space member."],["To call this method, specify authorization scopes for desired event types and use the `ListSpaceEvents()` method with a filter to specify event types and date ranges."],["The provided Node.js code sample demonstrates listing events for new memberships and messages within a space, requiring replacement of `SPACE_NAME` with the space's ID."]]],["This guide details how to use the `list()` method on the `SpaceEvent` resource within the Google Chat API to track changes in a space, such as new memberships and messages. To use, authenticate as a space member and specify the desired event types using the `filter` parameter when calling `ListSpaceEvents()`. The method returns the latest resource versions, up to 28 days prior, with the ability to filter by date. An example is provided showing how to filter events about new memberships and messages.\n"]]