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

# PIN ベースの認可

> CLI ツールやゲームコンソールなど、ブラウザーを埋め込めない X アプリで、oauth_verifier として数値 PIN を入力する PIN ベース OAuth フローを使用します。

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

### PIN ベースの認可

PIN ベース OAuth フローは、[3-legged OAuth](/resources/fundamentals/authentication/oauth-1-0a/obtaining-user-access-tokens) プロセスの一種で、認可後にユーザーをリダイレクトするために Web ブラウザーにアクセスまたは埋め込めないアプリケーション向けです。そうしたアプリケーションの例には、コマンドラインアプリケーション、組み込みシステム、ゲームコンソール、そして特定の種類のモバイルアプリなどがあります。

PIN ベース OAuth フローは、`oauth_callback` を `oob` に設定した `request_token` でアプリが開始します。`oob` という用語は out-of-band OAuth を意味します。ユーザーは、ログインまたはアプリの認可のために依然として X を訪問しますが、アクセスを承認した時点でアプリケーションに自動的にリダイレクトされることはありません。代わりに、数値の PIN コードが表示され、アプリケーションに戻ってこの値を入力するよう指示されます。

<Note>
  **注:** PIN ベース認証を使用する場合でも、X アプリ設定内の `callback_url` は依然として必須です。
</Note>

#### PIN ベース OAuth フローの実装

PIN ベースのフローは、以下の違いを除き、[3-legged 認可](/resources/fundamentals/authentication/oauth-1-0a/obtaining-user-access-tokens) (および [Sign in with X](/resources/fundamentals/authentication#log-in-with-x)) と同じ方法で実装します:

1. [POST oauth/request\_token](/resources/fundamentals/authentication/api-reference#post-oauth-request-token) 呼び出しの際、`oauth_callback` の値を `oob` に設定する必要があります。

2. ユーザーが [GET oauth/authenticate](/resources/fundamentals/authentication/api-reference#get-oauth-authenticate) または [GET oauth/authorize URL](/resources/fundamentals/authentication/api-reference#get-oauth-authorize) を使用してアプリを認可するために X に送信された後、`callback_url` にリダイレクトされず、代わりに X が生成した約 7 桁の PIN と、その PIN をアプリケーションに入力するよう指示する画面が表示されます。

3. ユーザーがこの PIN をアプリケーションに入力し、アプリケーションはその PIN 番号を [POST oauth/access\_token](/resources/fundamentals/authentication/api-reference#post-oauth-access-token) の `oauth_verifier` として使用し、access\_token を取得します。

<Note>
  **注:** PIN 番号は再利用できません。また、取得した `access_token` は application-user リクエストに使用してください。
</Note>
