> ## 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.

# OAuth APIリファレンス インデックス

<div id="oauth-10a">
  ### OAuth 1.0a
</div>

|                                                                                                                                  |                                                                                                                     |
| :------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------ |
| **目的**                                                                                                                           | メソッド                                                                                                                |
| 3-legged OAuth フローおよび Sign in with X におけるステップ 1  <br />Consumer アプリケーションがユーザー認可をリクエストするための OAuth Request Token を取得できるようにします。     | [POST oauth/request\_token](/ja/resources/fundamentals/authentication/api-reference#post-oauth-request-token)       |
| 3-legged OAuth フローおよび Sign in with X におけるステップ 2  <br />Consumer アプリケーションが OAuth Request Token を使用してユーザー認可をリクエストできるようにします。        | [GET oauth/authenticate](/ja/resources/fundamentals/authentication/api-reference#get-oauth-authenticate)            |
| 3-legged OAuth フローおよび Sign in with X におけるステップ 2  <br />Consumer アプリケーションが OAuth Request Token を使用してユーザー認可をリクエストできるようにします。        | [GET oauth/authorize](/ja/resources/fundamentals/authentication/api-reference#get-oauth-authorize)                  |
| 3-legged OAuth フローおよび Sign in with X におけるステップ 3  <br />Consumer アプリケーションが OAuth Request Token を OAuth Access Token と交換できるようにします。 | [POST oauth/access\_token](/ja/resources/fundamentals/authentication/api-reference#post-oauth-access-token)         |
| 登録済みアプリケーションが、発行済みの OAuth Access Token を無効化できるようにします。                                                                            | [POST oauth/invalidate\_token](/ja/resources/fundamentals/authentication/api-reference#post-oauth-invalidate-token) |

<div id="oauth-20-bearer-token">
  ### OAuth 2.0 ベアラートークン
</div>

|                                                                                              |                                                                                                                       |
| :------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------- |
| **Purpose**                                                                                  | メソッド                                                                                                                  |
| 登録済みの App が OAuth 2 のアプリ専用ベアラートークンを生成し、ユーザーコンテキストなしにその App を代表して API リクエストを行うために使用できるようにします。 | [POST oauth2/token](/ja/resources/fundamentals/authentication/api-reference#post-oauth2-token)                        |
| 登録済みの App が、発行済みの OAuth 2 アプリ専用ベアラートークンを失効させることができるようにします。                                   | [POST oauth2/invalidate\_token](/ja/resources/fundamentals/authentication/api-reference#post-oauth2-invalidate-token) |

<div id="post-oauthrequest_token">
  ### POST oauth/request\_token
</div>

Consumer アプリケーションがユーザー認可をリクエストするための OAuth Request Token を取得できるようにします。このメソッドは、[OAuth 1.0 authentication flow](http://oauth.net/core/1.0/#anchor9) の [Section 6.1](https://oauth.net/core/1.0/#auth_step1) に対応します。

**すべての OAuth 認可ステップで HTTPS を使用する必要があります。**

**使用上の注意：** `oauth_nonce` には ASCII 文字のみが使用できます。

**Resource URL[](#resource-url "Permalink to this headline")**

`https://api.x.com/oauth/request_token`

**Resource Information[](#resource-information "Permalink to this headline")**

|                          |      |
| :----------------------- | :--- |
| Response formats         | JSON |
| Requires authentication? | No   |
| Rate limited?            | Yes  |

**Parameters[](#parameters "Permalink to this headline")**

| Name                  | Required | Description                                                                                                                                                                                                                                                                                                                                                               | Example                                                          |
| :-------------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------- |
| oauth\_callback       | required | OAuth 1.0a 準拠のため、このパラメータは**必須**です。ここで指定した値は、ユーザーがあなたのアプリケーションによる自分のアカウントへのアクセスを承認した場合に、ユーザーがリダイレクトされる URL として使用されます。アウトオブバンドの PIN モードの場合は、これを `oob` に設定します。これは、デスクトップ / モバイルアプリケーションで使用するカスタムコールバックを指定する方法でもあります。事前登録済みのコールバックがあるかどうかに関わらず、このステップでは必ず `oauth_callback` を送信してください。<br /><br />このエンドポイントで使用されるコールバック URL は、developer.x.com 上の App の設定内で事前に構成されている必要があります。\* | `http://themattharris.local/auth.php` `twitterclient://callback` |
| x\_auth\_access\_type | optional | アプリケーションがユーザーアカウントに要求するアクセスレベルを上書きします。サポートされている値は `read` または `write` です。このパラメータは、開発者が read/write アプリケーションとして登録しつつ、適切な場合には読み取り専用アクセスのみを要求できるようにすることを意図しています。                                                                                                                                                                                                               |                                                                  |

コールバック URL の承認方法については、[このページ](/ja/resources/fundamentals/developer-apps#callback-urls)を参照してください。

**注意:** developer.x.com 上で X アカウントにログインしている場合、既存の [X apps](/ja/resources/fundamentals/developer-apps) は [X app dashboard](https://developer.x.com/en/apps) から表示および編集できます。

**Example request[](#example-request "Permalink to this headline")**

Request URL: `POST https://api.x.com/oauth/request_token`

Request POST Body: *N/A*

Authorization Header: `OAuth oauth_nonce="K7ny27JTpKVsTgdyLdDfmQQWVLERj2zAK5BslRsqyw", oauth_callback="http%3A%2F%2Fmyapp.com%3A3005%2Ftwitter%2Fprocess_callback", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1300228849", oauth_consumer_key="OqEqJeafRSF11jBMStrZz", oauth_signature="Pc%2BMLdv028fxCErFyi8KXFM%2BddU%3D", oauth_version="1.0"`

Response: `oauth_token=Z6eEdO8MOmk394WozF5oKyuAv855l4Mlqo7hhlSLik&oauth_token_secret=Kd75W4OQfb2oJTV0vzGzeXftVAwgMnEK9MumzYcM&oauth_callback_confirmed=true`

<div id="get-oauthauthorize">
  ### GET oauth/authorize
</div>

コンシューマーアプリケーションが OAuth Request Token を使用してユーザー認可を要求できるようにします。このメソッドは、[OAuth 1.0 認証フロー](http://oauth.net/core/1.0/#anchor9)における [セクション 6.2](http://oauth.net/core/1.0/#auth_step2) に相当します。デスクトップアプリケーションはこのメソッドを使用する必要があり ([GET oauth / authenticate](/ja/resources/fundamentals/authentication/api-reference#get-oauth-authenticate) は使用できません) 、他のメソッドは利用できません。

**使用上の注意:** `oauth_callback` がこのメソッドに送信されることはありません。代わりに [POST oauth / request\_token](/ja/resources/fundamentals/authentication/api-reference#post-oauth-request-token) に指定してください。

**リソース URL[](#resource-url "Permalink to this headline")**

`https://api.x.com/oauth/authorize`

**リソース情報[](#resource-information "Permalink to this headline")**

|              |      |
| :----------- | :--- |
| レスポンス形式      | JSON |
| 認証は必要ですか？    | はい   |
| レート制限はありますか？ | はい   |

**パラメータ[](#parameters "Permalink to this headline")**

|              |    |                                            |        |    |
| :----------- | :- | :----------------------------------------- | :----- | :- |
| 名前           | 必須 | 説明                                         | デフォルト値 | 例  |
| force\_login | 任意 | 正しいユーザーアカウントが認可されるように、ユーザーに資格情報の入力を必ず求めます。 |        |    |
| screen\_name | 任意 | OAuth ログイン画面のユーザー名入力欄に、指定した値をあらかじめ入力します。   |        |    |

**リクエスト例[](#example-request "Permalink to this headline")**

`oauth/authorize` ステップにユーザーを Web ブラウザで遷移させる際に、oauth\_token パラメータを含めます:
`https://api.x.com/oauth/authorize?oauth_token=Z6eEdO8MOmk394WozF5oKyuAv855l4Mlqo7hhlSLik`

<div id="get-oauthauthenticate">
  ### GET oauth/authenticate
</div>

Consumer アプリケーションが OAuth の `request_token` を使用して、ユーザーによる認可をリクエストできるようにします。

このメソッドは、コールバック認証フローを使用するアプリケーション向けの [OAuth 1.0 認証フロー](http://oauth.net/core/1.0/#anchor9) の [セクション 6.2](http://oauth.net/core/1.0/#auth_step2) を置き換えるものです。`force_login` パラメーターが `true` に設定されていない限り、このメソッドは現在ログインしているユーザーを、アクセス許可を与える対象アカウントとして使用します。

このメソッドは、ユーザーが既にアプリケーションに権限を付与している場合、ユーザーが再承認することなくリダイレクトが行われる点で、[GET oauth / authorize](/ja/resources/fundamentals/authentication/api-reference#get-oauth-authorize) と異なります。この挙動を実現するには、[application record](https://developer.x.com/apps) 上で *Use Sign in with X* 設定を有効にする必要があります。

**Resource URL[](#resource-url "Permalink to this headline")**

`https://api.x.com/oauth/authenticate`

**Resource Information[](#resource-information "Permalink to this headline")**

|                          |      |
| :----------------------- | :--- |
| Response formats         | JSON |
| Requires authentication? | Yes  |
| Rate limited?            | Yes  |

**Parameters[](#parameters "Permalink to this headline")**

|              |          |                                                   |               |         |
| :----------- | :------- | :------------------------------------------------ | :------------ | :------ |
| Name         | Required | Description                                       | Default Value | Example |
| force\_login | optional | 意図したユーザーのアカウントが認可されることを保証するため、ユーザーに資格情報の入力を強制します。 |               | *true*  |
| screen\_name | optional | OAuth ログイン画面のユーザー名入力ボックスを、指定した値であらかじめ入力します。       |               |         |

**Example request[](#example-request "Permalink to this headline")**

ブラウザーでユーザーを `oauth/authenticate` ステップにリダイレクトし、oauth\_token パラメーターを含めます:
`https://api.x.com/oauth/authenticate?oauth_token=Z6eEdO8MOmk394WozF5oKyuAv855l4Mlqo7hhlSLik`

<div id="post-oauthaccess_token">
  ### POST oauth/access\_token
</div>

Consumer アプリケーションが OAuth Request Token を OAuth Access Token に交換できるようにします。このメソッドは、[OAuth 1.0 authentication flow](http://oauth.net/core/1.0/#anchor9) の [セクション 6.3](http://oauth.net/core/1.0/#auth_step3) に対応します。

**Resource URL[](#resource-url "Permalink to this headline")**

`https://api.x.com/oauth/access_token`

**Resource Information[](#resource-information "Permalink to this headline")**

|                          |      |
| :----------------------- | :--- |
| Response formats         | JSON |
| Requires authentication? | Yes  |
| Rate limited?            | Yes  |

**Parameters[](#parameters "Permalink to this headline")**

|                 |          |                                                                                                                                                                                                                                            |               |         |
| :-------------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ | :------ |
| Name            | Required | Description                                                                                                                                                                                                                                | Default Value | Example |
| oauth\_token    | required | ここで指定する oauth\_token は、request\_token ステップで返された oauth\_token と同じである必要があります。                                                                                                                                                                |               |         |
| oauth\_verifier | required | OAuth の Web フローを使用している場合、このパラメータをコールバック URL で返された *oauth\_verifier* の値に設定します。アウトオブバンド OAuth を使用している場合、この値を PIN コードに設定します。OAuth 1.0a に準拠するには、このパラメータは**必須**です。OAuth 1.0a は厳密に適用されており、*oauth\_verifier* を使用していないアプリケーションは OAuth フローを完了できません。 |               |         |

**Example request[](#example-request "Permalink to this headline")**

`POST https://api.x.com/oauth/access_token?oauth_token=qLBVyoAAAAAAx72QAAATZxQWU6P&oauth_verifier=ghLM8lYmAxDbaqL912RZSRjCCEXKDIzx`

PIN ベースの場合: `POST https://api.x.com/oauth/access_token?oauth_token=9Npq8AAAAAAAx72QBRABZ4DAfY9&oauth_verifier=4868795`

**Example response[](#example-response "Permalink to this headline")**

`oauth_token=6253282-eWudHldSbIaelX7swmsiHImEL4KinwaGloHANdrY&oauth_token_secret=2EEfA6BG5ly3sR3XjE0IBSnlQu4ZrUzPiYTmrkVU&user_id=6253282&screen_name=xapi`

<div id="post-oauthinvalidate_token">
  ### POST oauth/invalidate\_token
</div>

登録済みアプリケーションは、自身のクライアント認証情報を提示することで、発行済みの OAuth `access_token` を失効させることができます。いったん `access_token` が失効すると、新たに作成を試みた場合でも別のアクセス・トークンが発行され、失効済みトークンは以後使用できなくなります。

**Resource URL[](#resource-url "Permalink to this headline")**

`https://api.x.com/1.1/oauth/invalidate_token`

**Resource Information[](#resource-information "Permalink to this headline")**

|                          |                                    |
| :----------------------- | :--------------------------------- |
| Response formats         | JSON                               |
| Requires authentication? | Yes - 失効させたいアクセス・トークンを持つユーザーコンテキスト |
| Rate limited?            | Yes                                |

**Example request[](#example-request "Permalink to this headline")**

```bash theme={null}
        curl --request POST
          --url 'https://api.x.com/1.1/oauth/invalidate_token.json'
          --header 'authorization: OAuth oauth_consumer_key="CLIENT_KEY",
         oauth_nonce="AUTO_GENERATED_NONCE", oauth_signature="AUTO_GENERATED_SIGNATURE",
         oauth_signature_method="HMAC-SHA1", oauth_timestamp="AUTO_GENERATED_TIMESTAMP",
         oauth_token="ACCESS_TOKEN", oauth_version="1.0"'
```

**レスポンス例[](#example-response "この見出しへのパーマリンク")**

```bash theme={null}
        HTTP/1.1 200 OK
        Content-Type: application/json; charset=utf-8
        Content-Length: 127
        ...

        {"access_token":"ACCESS_TOKEN"}
```

**トークンが失効した後のエラーレスポンス例[](#example-error-response-after-token-has-been-invalidated "この見出しへのパーマリンク")**

```bash theme={null}
        HTTP/1.1 401 Authorization Required
        ...

        {"errors": [{
          "code": 89,
          "message": "Invalid or expired token."}
        ]}
```

<div id="post-oauth2token">
  ### POST oauth2/token
</div>

登録済みアプリケーションが OAuth 2 ベアラートークンを取得するためのエンドポイントです。このトークンはユーザーコンテキストなしに、アプリケーション自身を代表して API リクエストを行うために使用できます。これは [アプリケーション専用認証](/ja/resources/fundamentals/authentication/oauth-2-0/application-only) と呼ばれます。

ベアラートークンは oauth2/invalidate\_token を使用して無効化できます。ベアラートークンが一度無効化されると、新しく作成を試みた場合には別のベアラートークンが付与され、以前のトークンは使用できなくなります。

1 つのアプリケーションに対して未失効のベアラートークンは 1 つだけであり、このメソッドへの繰り返しのリクエストは、そのトークンが無効化されるまでは、すでに存在している同じトークンを返します。

成功したレスポンスには、付与されたベアラートークンを記述する JSON 構造が含まれます。

このメソッドで受け取ったトークンはキャッシュする必要があります。あまりに頻繁に試行した場合、リクエストはコード 99 を伴う HTTP 403 で拒否されます。

**Resource URL[](#resource-url "Permalink to this headline")**

`https://api.x.com/oauth2/token`

**Resource Information[](#resource-information "Permalink to this headline")**

|                          |                                                             |
| :----------------------- | :---------------------------------------------------------- |
| Response formats         | JSON                                                        |
| Requires authentication? | Yes - API key をユーザー名、API key secret をパスワードとする Basic 認証が必要です |
| Rate limited?            | Yes                                                         |

**Parameters[](#parameters "Permalink to this headline")**

|             |          |                                                                                                                                                                                                  |               |                       |
| :---------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ | :-------------------- |
| Name        | Required | Description                                                                                                                                                                                      | Default Value | Example               |
| grant\_type | required | アプリケーションが要求している grant type を指定します。現時点では *client\_credentials* のみが許可されています。詳細は [Application-Only Authentication](/ja/resources/fundamentals/authentication/oauth-2-0/application-only) を参照してください。 |               | *client\_credentials* |

**Example request[](#example-request "Permalink to this headline")**

```bash theme={null}
    POST /oauth2/token HTTP/1.1
    Host: api.x.com
    User-Agent: My X App v1.0.23
    Authorization: Basic eHZ6MWV2R ... o4OERSZHlPZw==
    Content-Type: application/x-www-form-urlencoded;charset=UTF-8
    Content-Length: 29
    Accept-Encoding: gzip

    grant_type=client_credentials
```

**レスポンス例:**

```bash theme={null}
    HTTP/1.1 200 OK
    Status: 200 OK
    Content-Type: application/json; charset=utf-8
    ...
    Content-Encoding: gzip
    Content-Length: 140

    {"token_type":"bearer","access_token":"AAAA%2FAAA%3DAAAAAAAA"}
```

<div id="post-oauth2invalidate_token">
  ### POST oauth2/invalidate\_token
</div>

登録済みのアプリケーションが、自身のクライアント認証情報を提示することで、発行済みの OAuth 2.0 ベアラートークンを失効させることができます。一度ベアラートークンが無効化されると、それ以降に新しく発行されるベアラートークンは別の値となり、無効化されたトークンは使用できなくなります。

成功したレスポンスには、失効したベアラートークンを表す JSON 構造が含まれます。

**Resource URL[](#resource-url "Permalink to this headline")**

`https://api.x.com/oauth2/invalidate_token`

**Resource Information[](#resource-information "Permalink to this headline")**

|                          |                                                                                                                                               |
| :----------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------- |
| Response formats         | JSON                                                                                                                                          |
| Requires authentication? | Yes - アプリケーションのコンシューマー API キーおよびアプリケーション所有者のアクセス・トークンとアクセス・トークン・シークレットを用いた [OAuth 1.0a](/ja/resources/fundamentals/authentication/oauth-1-0a) |
| Rate limited?            | Yes                                                                                                                                           |

**Parameters[](#parameters "Permalink to this headline")**

| Name          | Required | Description      |
| :------------ | :------- | :--------------- |
| access\_token | required | 無効化したいベアラートークンの値 |

**Example request[](#example-request "Permalink to this headline")**

```
        curl --request POST
          --url 'https://api.x.com/oauth2/invalidate_token?access_token=AAAA%2FAAA%3DAAAAAAAA'
          --header 'authorization: OAuth oauth_consumer_key="CLIENT_KEY",
         oauth_nonce="AUTO_GENERATED_NONCE", oauth_signature="AUTO_GENERATED_SIGNATURE",
         oauth_signature_method="HMAC-SHA1", oauth_timestamp="AUTO_GENERATED_TIMESTAMP",
         oauth_token="ACCESS_TOKEN", oauth_version="1.0"'
```

**レスポンス例[](#example-response "Permalink to this headline")**

```
         Status: 200 OK
         Content-Type: application/json; charset=utf-8
         Content-Length: 135
         ...
       {
        "access_token": "AAAA%2FAAA%3DAAAAAAAA"
        }
```
