List custom emojis in an organization
Stay organized with collections
Save and categorize content based on your preferences.
This guide explains how to use the
list
method on the
CustomEmoji
resource of the Google Chat API to list custom emoji visible to the authenticated user in a Google Workspace organization.
Custom emojis are only available for Google Workspace accounts, and your administrator must turn custom emoji on for your organization. For more information, see Learn about custom emoji in Google Chat and Manage custom emoji permissions.
Prerequisites
Node.js
- A Business or Enterprise Google Workspace account with access to Google Chat.
- Set up your environment:
- Create a Google Cloud project.
- Configure the OAuth consent screen.
- Enable and configure the Google Chat API with a name, icon, and description for your Chat app.
- Install the Node.js Cloud Client Library.
- Create access credentials based on how you want to authenticate in your Google Chat API
request:
- To authenticate as a Chat user,
create OAuth client ID
credentials and save the credentials as a JSON file named
credentials.json
to your local directory. - To authenticate as the Chat app,
create service account
credentials and save the credentials as a JSON file named
credentials.json
.
- To authenticate as a Chat user,
create OAuth client ID
credentials and save the credentials as a JSON file named
- Choose an authorization scope based on whether you want to authenticate as a user or the Chat app.
List custom emoji in an organization
To list custom emoji in an organization with user authentication, pass the following in your request:
- Specify the
chat.customemojis
authorization scope. - Call the
ListCustomEmojis
method.
The following example list custom emoji in an organization.
Node.js
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 credential asyncfunctionmain(){ // Create a client constchatClient=awaitcreateClientWithUserCredentials( USER_AUTH_OAUTH_SCOPES, ); // Initialize request argument(s) constrequest={ // Optional. Replace FILTER here filter:'FILTER', }; // Make the request constpageResult=awaitchatClient.listCustomEmojisAsync(request); // Handle the response. Iterating over pageResult will yield results and // resolve additional pages automatically. forawait(constresponseofpageResult){ console.log(response); } } awaitmain();
To run this sample, replace the following:
FILTER
: Optional, the filter to apply to the list request.