Lister les emoji personnalisés dans une organisation
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Ce guide explique comment utiliser la méthode list sur la ressource CustomEmoji de l'API Google Chat pour lister les emoji personnalisés visibles par l'utilisateur authentifié dans une organisation Google Workspace.
Créez des identifiants d'accès en fonction de la façon dont vous souhaitez vous authentifier dans votre requête API Google Chat :
Pour vous authentifier en tant qu'utilisateur Chat, créez des identifiants d'ID client OAuth et enregistrez-les dans un fichier JSON nommé credentials.json dans votre répertoire local.
import{createClientWithUserCredentials}from'./authentication-utils.js';constUSER_AUTH_OAUTH_SCOPES=['https://www.googleapis.com/auth/chat.customemojis'];// This sample shows how to get custom emoji with user credentialasyncfunctionmain(){// Create a clientconstchatClient=awaitcreateClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);// Initialize request argument(s)constrequest={// Optional. Replace FILTER herefilter:'FILTER'};// Make the requestconstpageResult=awaitchatClient.listCustomEmojisAsync(request);// Handle the response. Iterating over pageResult will yield results and// resolve additional pages automatically.forawait(constresponseofpageResult){console.log(response);}}main().catch(console.error);
Pour exécuter cet exemple, remplacez les éléments suivants :
FILTER : filtre facultatif à appliquer à la requête de liste.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/04 (UTC).
[null,null,["Dernière mise à jour le 2025/08/04 (UTC)."],[],[],null,["# List custom emojis in an organization\n\nThis guide explains how to use the\n[`list`](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ChatService.ListCustomEmojis)\nmethod on the\n[`CustomEmoji`](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.CustomEmoji)\nresource of the Google Chat API to list custom emoji visible to the authenticated user in a Google Workspace organization.\n\nCustom emojis are only available for Google Workspace accounts, and your\nadministrator must turn custom emoji on for your organization. For more\ninformation, see [Learn about custom emoji in Google Chat](https://support.google.com/chat/answer/12800149) and\n[Manage custom emoji permissions](https://support.google.com/a/answer/12850085).\n\nPrerequisites\n-------------\n\n\n### Node.js\n\n\n- A Business or Enterprise [Google Workspace](https://support.google.com/a/answer/6043576) account with access to [Google Chat](https://workspace.google.com/products/chat/).\n\n\u003c!-- --\u003e\n\n- Set up your environment:\n - [Create a Google Cloud project](/workspace/guides/create-project).\n - [Configure the OAuth consent screen](/workspace/guides/configure-oauth-consent).\n - [Enable and configure the Google Chat API](/workspace/chat/configure-chat-api) with a name, icon, and description for your Chat app.\n - Install the Node.js [Cloud Client Library](/workspace/chat/libraries?tab=nodejs#cloud-client-libraries).\n - Create access credentials based on how you want to authenticate in your Google Chat API request:\n - To authenticate as a Chat user, [create OAuth client ID\n credentials](/workspace/chat/authenticate-authorize-chat-user) and save the credentials as a JSON file named `credentials.json` to your local directory.\n - To authenticate as the Chat app, [create service account\n credentials](/workspace/chat/authenticate-authorize-chat-app) and save the credentials as a JSON file named `credentials.json`.\n- [Choose an authorization scope](/workspace/chat/authenticate-authorize#asynchronous-chat-calls) based on whether you want to authenticate as a user or the Chat app.\n\n\u003cbr /\u003e\n\n\n| The code samples in this page use the gRPC API interface with the Google Cloud client libraries. Alternatively, you can use the REST API interface. For more information about the gRPC and REST interfaces, see [Google Chat API overview](/workspace/chat/api/reference).\n\n\u003cbr /\u003e\n\nList custom emoji in an organization\n------------------------------------\n\nTo list custom emoji in an organization with\n[user authentication](/workspace/chat/authenticate-authorize-chat-user), pass\nthe following in your request:\n\n- Specify the `chat.customemojis` authorization scope.\n- Call the [`ListCustomEmojis`](/workspace/chat/api/reference/rpc/google.chat.v1#google.chat.v1.ChatService.ListCustomEmojis) method.\n\nThe following example list custom emoji in an organization. \n\n### Node.js\n\nchat/client-libraries/cloud/list-custom-emojis-user-cred.js \n[View on GitHub](https://github.com/googleworkspace/node-samples/blob/main/chat/client-libraries/cloud/list-custom-emojis-user-cred.js) \n\n```javascript\nimport {createClientWithUserCredentials} from './authentication-utils.js';\n\nconst USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.customemojis'];\n\n// This sample shows how to get custom emoji with user credential\nasync function main() {\n // Create a client\n const chatClient = await createClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);\n\n // Initialize request argument(s)\n const request = {\n // Optional. Replace FILTER here\n filter: 'FILTER'\n };\n\n // Make the request\n const pageResult = await chatClient.listCustomEmojisAsync(request);\n\n // Handle the response. Iterating over pageResult will yield results and\n // resolve additional pages automatically.\n for await (const response of pageResult) {\n console.log(response);\n }\n}\n\nmain().catch(console.error);\n```\n\nTo run this sample, replace the following:\n\n- \u003cvar translate=\"no\"\u003eFILTER\u003c/var\u003e: Optional, the filter to apply to the list request.\n\nRelated topics\n--------------\n\n- [Create a custom emoji](/workspace/chat/create-custom-emoji)\n- [Delete a custom emoji](/workspace/chat/delete-custom-emoji)\n- [Get details about a custom emoji](/workspace/chat/get-custom-emoji)"]]