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

# API Key と Secret

> X API Key と Secret (consumer key と secret) が何であるか、Developer Portal での作成方法、再生成やローテーション方法を学びます。

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>;
};

### API Key と Secret

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

これらの認証情報は、[認証エンドポイント](/resources/fundamentals/authentication/api-reference) で [ユーザー Access Token と Secret](/resources/fundamentals/authentication/oauth-1-0a/api-key-and-secret) や [Bearer Token](/resources/fundamentals/authentication/oauth-2-0/bearer-tokens) など、追加の認証情報を生成するために使用できます。また、OAuth 1.0a User Context 認証が必要な [リクエストを認可する](/resources/fundamentals/authentication/oauth-1-0a/authorizing-a-request) 際に、Access Token やその他の認可パラメーターと共にこれらの認証情報を使用する必要もあります。

#### API Key と Secret の取得方法

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

1. [X デベロッパーアカウントに登録する](https://developer.x.com/en/apply-for-access)
2. [Developer Console](/resources/fundamentals/developer-portal) 内で [X アプリ](/resources/fundamentals/developer-apps) を作成する。[X API v2](/x-api/introduction) を利用したい場合は、デベロッパーアプリのキーとトークンを使用する必要があります。

X アプリを作成すると、API Key、Secret、および Bearer Token が表示されます。これらの認証情報は 1 回のみ表示されるため、パスワードマネージャーや安全な場所に必ず保存してください。

キーとトークンの取り扱い方法や認証情報が漏洩した場合の対処方法など、詳細な推奨事項については [認証のベストプラクティス](/resources/fundamentals/authentication/guides/authentication-best-practices) ページを参照してください。

#### アプリ作成後に API Key と Secret を見つけて再生成する方法

すでにアプリを作成しており、API Key と Secret を見つけたり再生成したりする必要がある場合は、次の手順に従ってください:

1. Developer Console に移動します
2. サイドナビの「Apps」ドロップダウンを展開します
3. 見つけたい、または再生成したい API Key と Secret に関連付けられたアプリを開きます
4. Keys and tokens タブに移動します

そこで、アプリに関連付けられたすべての認証情報を確認できます。

#### API Key と Secret の使い方

X Developer Platform を試している段階であれば、[ツールまたはライブラリ](/resources/tools-and-libraries) を使ってプラットフォームで何ができるかを確認することをお勧めします。これらのツールは認証を適切に処理し、多くの時間と手間を節約できます。特に初心者のデベロッパーには、[Postman を使ったスタート](/tutorials/postman-getting-started) または [Insomnia](https://insomnia.rest/) をお勧めします。

リクエストをゼロから構築することに興味がある場合は、[OAuth 1.0a リクエストの認可](/resources/fundamentals/authentication/oauth-1-0a/authorizing-a-request) ガイドをお読みください。
