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

# GitHub

> AI agentをGitHubに接続すると、リポジトリへのアクセス、Issueの管理、開発者向けワークフローを利用できます。

AI AgentをGitHubに接続すると、リポジトリへのアクセス、Issueの管理、開発者ワークフローを利用できるようになります。

## GitHubをAuth0に接続する

**GitHubアプリの権限：** GitHubアプリは[きめ細かな権限を使用する](https://docs.github.com/en/enterprise-server@3.17/apps/oauth-apps/building-oauth-apps/differences-between-github-apps-and-oauth-apps#requesting-permission-levels-for-resources)ため、Token Vaultの構成時に権限をリクエストすることはできません。必要な権限は、GitHubの開発者設定でGitHubアプリを作成する際に設定してください。

**1. GitHubのセットアップ**

<ol>
  <li>
    [GitHub開発者アカウント](https://github.com/signup)にサインアップします
  </li>

  <li>
    [GitHub Developer Settings > GitHub
    Apps](https://github.com/settings/apps/new)から新しいGitHubアプリをセットアップします
  </li>

  <li>
    GitHubアプリを構成する際は、以下の設定を使用します：

    <ul>
      <li>**Homepage URL**: `https://YOUR_AUTH0_DOMAIN`</li>
      <li>**Callback URL**: `https://YOUR_AUTH0_DOMAIN/login/callback`</li>
      <li>**Webhook Active**: 無効</li>
      <li>**Permissions**: アプリに必要な権限を選択します</li>
    </ul>

    You can find the **Auth0 domain** in the [Auth0 Dashboard](https://manage.auth0.com/).

    You can find this under **Applications > \[Your Application] > Settings > Basic Information > Domain**.

    If you are using the [custom domains](/docs/customize/custom-domains) feature, your Auth0 domain is the custom domain. You can find this under **Branding > Custom Domains**.
  </li>

  <li>
    **Create**を選択し、表示される**App settings**ページで新しいclient secretを生成します。
  </li>

  <li>**Client ID**と**Client Secret**を控えておきます</li>
</ol>

**2. Auth0のセットアップ**

<ol>
  <li>
    [Auth0 Dashboard](https://manage.auth0.com/)で、
    **［Authentication］>［Social］** に移動します。**［Create Connection］** を選択し、次に
    **［GitHub］** を選択して、**［続行］** を選択します。
  </li>

  <li>
    **［General］** で、作成したGitHub OAuthアプリの**Client ID**と**Client Secret**を入力します。
  </li>

  <li>
    **［用途］** で、**［Connected Accounts for Token Vault］** をオンにします。これにより、この接続で外部APIのアクセストークンを取得し、安全に保存できるようになります。詳細については、[Connected Accounts for Token
    Vault](/docs/ja-jp/secure/call-apis-on-users-behalf/token-vault/connected-accounts-for-token-vault)を参照してください。
  </li>

  <li>**［Create］** を選択します。</li>

  <li>
    保存後、**［アプリケーション］** タブに移動し、この接続を使用するアプリケーションを選択します。
  </li>
</ol>

アプリケーションで[Organizations](/docs/ja-jp/manage-users/organizations)を使用している場合は、Connected Accounts フローを開始する前に、対象のOrganizationでユーザーを認証してください。その場合でも、Token VaultはGitHubの連携済みアカウントをユーザーのAuth0プロファイルに保存するため、Organizationの各メンバーがそれぞれ自分のGitHubアカウントを認可することになります。

このガイドでは、Auth0 で **GitHub** 接続をセットアップする手順を説明します。
このような接続を使用して、ユーザーに代わってアプリから第三者 API を呼び出す方法を一連の流れで示す例については、
[ユーザーに代わって第三者 API を呼び出すクイックスタート](/ai/docs/get-started/call-third-party-apis-on-users-behalf)をお読みください。

## Token Vault の設定例

GitHub 接続で Token Vault を設定するには、アプリケーションで次のコードスニペットを使用します。

**JavaScript**

```tsx wrap lines theme={null}
const auth0AI = new Auth0AI();

export const withGitHubConnection = auth0AI.withTokenVault({
  connection: "github",
  // GitHub ではまだスコープがサポートされていません。必要なスコープは、連携する GitHub アプリの作成時に設定してください
  scopes: [],
  refreshToken: getAuth0RefreshToken(),
});
```

**Python**

```python wrap lines theme={null}
auth0_ai = Auth0AI()

with_github_connection = auth0_ai.with_token_vault(
    connection="github",
    # GitHub ではまだスコープがサポートされていません。必要なスコープは、連携する GitHub アプリの作成時に設定してください
    scopes=[],
    refresh_token=get_auth0_refresh_token,
)
```

## Next steps

* To learn how to configure applications to access Token Vault, read [Configure Token Vault](/docs/secure/call-apis-on-users-behalf/token-vault/configure-token-vault).
* If your application uses [Organizations](/docs/manage-users/organizations), authenticate the user with the target organization before initiating the Connected Accounts flow. Connected accounts remain linked to the individual user profile.
* To learn how to get an access token to make a tool call, complete the [Call third-party APIs on user's behalf Quickstart](/ai/docs/get-started/call-third-party-apis-on-users-behalf).
