> ## Documentation Index
> Fetch the complete documentation index at: https://generaltranslation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# APIキーとシークレット

export const Button = ({href, children}) => {
  return <div className="not-prose group">
    <a href={href}>
      <button className="flex items-center space-x-2.5 py-1 px-4 bg-primary-dark dark:bg-white text-white dark:text-gray-950 rounded-full group-hover:opacity-[0.9] font-medium">
        <span>
          {children}
        </span>
        <svg width="3" height="24" viewBox="0 -9 3 24" class="h-6 rotate-0 overflow-visible"><path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>
      </button>
    </a>
  </div>;
};

<div id="api-key-and-secret">
  ### API Key と Secret
</div>

API Key と Secret (Consumer Key と Secret とも呼ばれます) は、X API にアクセスするために必要となる最も基本的な認証情報です。これらの認証情報は X App のユーザー名とパスワードのような役割を果たし、どの App からのリクエストかを X API が識別するために使用されます。

これらの認証情報は、[認証エンドポイント](/ja/resources/fundamentals/authentication/api-reference) によって、[ユーザーアクセストークンとシークレット](/ja/resources/fundamentals/authentication/oauth-1-0a/api-key-and-secret) や [ベアラートークン](/ja/resources/fundamentals/authentication/oauth-2-0/bearer-tokens) などの追加の認証情報を生成するために使用できます。また、OAuth 1.0a のユーザーコンテキスト認証を必要とするリクエストを[承認](/ja/resources/fundamentals/authentication/oauth-1-0a/authorizing-a-request)する際には、アクセストークンやその他の認可用パラメータと併せて、これらの認証情報を使用する必要があります。 

<div id="how-to-acquire-an-api-key-and-secret">
  #### API Key と Secret の取得方法
</div>

X API Key と Secret を取得するには、次の手順に従ってください。

1. [X 開発者アカウントに登録する](https://developer.x.com/en/apply-for-access)
2. [開発者コンソール](/ja/resources/fundamentals/developer-portal)内で [X App](/ja/resources/fundamentals/developer-apps) を作成します。[X API v2](/ja/x-api/introduction) を使用したい場合は、開発者 App のキーとトークンを使用する必要があることに注意してください。
    

X App を作成すると、API Key と Secret に加えて、ベアラートークンが表示されます。これらの認証情報は一度しか表示されないため、パスワードマネージャーなどの安全な場所に必ず保存してください。

キーやトークンの取り扱いについては、認証情報が漏えいした場合に取るべき対応も含めて、[認証に関するベストプラクティス](/ja/resources/fundamentals/authentication/guides/authentication-best-practices)のページで詳しく説明しています。
 

<div id="how-to-find-and-regenerate-your-api-key-and-secret-after-app-creation">
  #### App 作成後に API Key と Secret を見つけて再生成する方法
</div>

すでに App を作成済みで、API Key と Secret を確認または再生成する必要がある場合は、次の手順に従ってください。

1. 開発者コンソールにアクセスします
2. サイドナビで「Apps」ドロップダウンを展開します
3. 対象の API Key と Secret が関連付けられている App を開きます
4. 「Keys and tokens」タブを開きます

ここで、その App に関連付けられているすべての認証情報を確認できます。 
 

<div id="how-to-use-your-api-key-and-secret">
  #### API Key と Secret の使用方法
</div>

X Developer Platform をこれから探索している段階であれば、まずはプラットフォーム上でどのような機能が利用できるかを確認するために、[ツールやライブラリ](/ja/resources/tools-and-libraries)の利用をおすすめします。これらのツールは認証処理を適切に扱ってくれるため、多くの時間と手間を節約できます。特に、開発初心者の方には [Postman の始め方](/ja/tutorials/postman-getting-started) や [Insomnia](https://insomnia.rest/) の利用を推奨します。 

リクエストを一から自分で構築したい場合は、[OAuth 1.0a リクエストの認可](/ja/resources/fundamentals/authentication/oauth-1-0a/authorizing-a-request) に関するガイドを参照してください。
 
