列出组织中的自定义表情符号

本指南介绍了如何使用 Google Chat API 的 CustomEmoji 资源中的 list 方法,列出 Google Workspace 组织中经过身份验证的用户可见的自定义表情符号。

自定义表情符号仅适用于 Google Workspace 账号,并且您的管理员必须为贵组织启用自定义表情符号。如需了解详情,请参阅了解 Google Chat 中的自定义表情符号管理自定义表情符号权限

前提条件

Node.js

列出组织中的自定义表情符号

如需列出组织中具有用户身份验证功能的自定义表情符号,请在请求中传递以下内容:

以下示例列出了组织中的自定义表情符号。

Node.js

chat/client-libraries/cloud/list-custom-emojis-user-cred.js
import {createClientWithUserCredentials} from './authentication-utils.js';

const USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.customemojis'];

// This sample shows how to get custom emoji with user credential
async function main() {
  // Create a client
  const chatClient = await createClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);

  // Initialize request argument(s)
  const request = {
    // Optional. Replace FILTER here
    filter: 'FILTER'
  };

  // Make the request
  const pageResult = await chatClient.listCustomEmojisAsync(request);

  // Handle the response. Iterating over pageResult will yield results and
  // resolve additional pages automatically.
  for await (const response of pageResult) {
    console.log(response);
  }
}

main().catch(console.error);

如需运行此示例,请替换以下内容:

  • FILTER:可选,要应用于列表请求的过滤条件。