カスタム絵文字の詳細を取得する

このガイドでは、Google Chat API の CustomEmoji リソースで get メソッドを使用して、カスタム絵文字の詳細を取得する方法について説明します。

カスタム絵文字は Google Workspace アカウントでのみ使用できます。また、組織の管理者がカスタム絵文字を有効にする必要があります。詳しくは、Google Chat のカスタム絵文字についてカスタム絵文字の権限を管理するをご覧ください。

前提条件

Node.js

カスタム絵文字の詳細を取得する

ユーザー認証を使用してカスタム絵文字の詳細を取得するには、リクエストで次の情報を渡します。

  • chat.customemojis 認証スコープを指定します。
  • GetCustomEmoji メソッドを呼び出します。
  • リクエストの本文で、name を取得するカスタム絵文字のリソース名に設定します。

次の例では、カスタム絵文字の詳細を取得します。

Node.js

chat/client-libraries/cloud/get-custom-emoji-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 = {
    // TODO(developer): Replace EMOJI_NAME here
    name: 'customEmojis/EMOJI_NAME'
  };

  // Make the request
  const response = await chatClient.getCustomEmoji(request);

  // Handle the response
  console.log(response);
}

main().catch(console.error);

このサンプルを実行するには、次の値を置き換えます。

  • EMOJI_NAME: カスタム絵文字の一意の名前(emoji_name フィールド)。この ID は、ListCustomEmoji() メソッドを呼び出すか、Chat API でカスタム絵文字を非同期で作成した後に返されるレスポンスの本文から取得できます。