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

# アプリに GitHub ログインを追加する

> Auth0 を使用して、アプリケーションに GitHub サインインを追加する方法を学びます。OAuth 2.0 で GitHub のソーシャル接続を設定し、ユーザーが GitHub アカウントで認証できるようにします。

Auth0 は GitHub サインインをサポートしており、ユーザーは <Tooltip tip="OAuth 2.0: 認可プロトコルとワークフローを定義する認可フレームワーク。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=OAuth+2.0">OAuth 2.0</Tooltip> を通じて GitHub アカウントで認証できます。ソーシャルログインの選択肢として GitHub を追加することで、開発者や技術系ユーザーに、すばやく使い慣れたサインイン体験を提供できます。

この接続を設定するには、まず GitHub で OAuth アプリケーションを登録し、次に GitHub から提供される資格情報を使って Auth0 Dashboard で接続を設定します。

<Card title="開始する前に">
  GitHub をソーシャル接続として設定する前に、次のものが必要です。

  1. [Auth0 アカウント](https://auth0.com/signup)。まだお持ちでない場合は、無料で登録できます。
  2. [GitHub アカウント](https://github.com/signup)。
  3. [Auth0 Dashboard](https://manage.auth0.com/#/applications) に登録済みのアプリケーション。
</Card>

<div id="configure-github">
  ## GitHub を設定する
</div>

接続の設定に必要な資格情報を生成するため、GitHub で OAuth アプリケーションを作成します。

<Steps>
  <Step title="GitHub Developer Settings を開く">
    GitHub アカウントにログインします。右上のプロフィール写真を選択し、**Settings** を選択します。左側のサイドバーで **Developer settings** を選択し、続いて **OAuth Apps** を選択します。
  </Step>

  <Step title="新しい OAuth アプリケーションを登録する">
    **New OAuth App** を選択します。これまで一度もアプリケーションを作成したことがない場合は、**Register a new application** を選択します。

    次の項目を入力します。

    | **Field**                      | **Value**                                                     |
    | ------------------------------ | ------------------------------------------------------------- |
    | **Application name**           | たとえば `My App (Auth0)` のように、ユーザーが見て認識し、信頼できる名前                 |
    | **Homepage URL**               | たとえば `https://myapp.example.com` のような、アプリケーションのホームページの完全な URL |
    | **Application description**    | (任意) アプリケーションのすべてのユーザーに表示される説明                                |
    | **Authorization callback URL** | `https://YOUR_AUTH0_DOMAIN/login/callback`                    |

    `YOUR_AUTH0_DOMAIN` はご利用の Auth0 テナントのドメインに置き換えてください。この値は [Auth0 Dashboard > Applications > Applications](https://manage.auth0.com/#/applications) の **Settings** タブで確認できます。

    アプリケーションでデバイスベースの認可が必要でない限り、**Enable Device Flow** はオフのままでかまいません。

    **Register application** を選択します。
  </Step>

  <Step title="Client ID と Client Secret をコピーする">
    登録後、GitHub にアプリケーションの詳細ページが表示されます。**Client ID** の値をコピーします。

    **Generate a new client secret** を選択してシークレットを作成します。生成された値はすぐにコピーしてください。

    <Callout icon="file-lines" color="#0EA5E9" iconType="regular">
      GitHub では Client Secret は一度しか表示されません。ページを離れる前に、安全な場所に保管してください。紛失した場合は、新しく生成する必要があります。
    </Callout>
  </Step>
</Steps>

<div id="configure-auth0">
  ## Auth0 を設定する
</div>

GitHub 接続を Auth0 テナントに追加し、前のセクションで取得した資格情報を入力します。

<Steps>
  <Step title="GitHub 接続を作成する">
    [Auth0 Dashboard > Authentication > Social](https://manage.auth0.com/#/social) に移動し、**Create Connection** を選択します。プロバイダーの一覧から **GitHub** を選択します。
  </Step>

  <Step title="接続の用途を選択する">
    **Purpose** で、この接続の用途を指定します。ログイン、接続済みアカウント、またはその両方に使用できます。
  </Step>

  <Step title="GitHub の資格情報を入力する">
    **General** で、GitHub からコピーした **Client ID** と **Client Secret** を入力します。
  </Step>

  <Step title="権限を選択する">
    **Permissions** で、アプリケーションに必要な権限を選択します。ほとんどのアプリケーションでは、ユーザーのメールアドレスには **Email address**、プロファイル情報には **Read user** が必要です。
  </Step>

  <Step title="接続を保存して有効にする">
    接続を保存するには **Create** を選択します。

    **Applications** タブを選択し、GitHub ログインを提供するアプリケーションでこの接続を有効にします。
  </Step>
</Steps>

<div id="test-the-connection">
  ## 接続をテストする
</div>

本番環境にデプロイする前に、GitHub 接続が正しく機能することを確認します。

1. [Auth0 Dashboard > Authentication > Social](https://manage.auth0.com/#/social) に移動します。
2. 一覧から GitHub 接続を選択します。
3. **Try Connection** を選択します。
4. 求められたら、GitHub アカウントで認証します。
5. ユーザーの GitHub ユーザー名やメールアドレスを含むユーザープロファイルデータが Auth0 から返されることを確認します。

<div id="keep-reading">
  ## 続きを読む
</div>

* [アプリに Google Login を追加する](/docs/ja-jp/authenticate/identity-providers/social-identity-providers/google)
* [Auth0 Developer Keys を使用してソーシャル接続をテストする](/docs/ja-jp/authenticate/identity-providers/social-identity-providers/devkeys)
* [カスタムソーシャル接続を作成する](/docs/ja-jp/authenticate/identity-providers/social-identity-providers/oauth2)
