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

# Google

> AI agent を Gmail、Google カレンダー、Google ドライブなどの Google サービスに接続します。

Google 連携を使用すると、ユーザーは自分の Google プロファイルで AI agent にログインできるようになります。[ユーザーに代わってサードパーティ API を呼び出すクイックスタート](/ai/docs/ja-jp/get-started/call-third-party-apis-on-users-behalf)を完了するには、Google ソーシャル接続をセットアップする必要があります。

Google ソーシャル接続をセットアップするには、次の手順を行います。

* Google Auth Platform で Google OAuth 認証情報を作成する
* Auth0 Dashboard で Google ソーシャル接続を構成してテストする

## 前提条件

1. [Google Cloud アカウントにサインアップします](https://console.cloud.google.com/)。
2. [Google プロジェクトを作成します](https://docs.cloud.google.com/resource-manager/docs/creating-managing-projects)。

## Google Auth Platform

Google Auth Platformを使用すると、ログインやGoogle APIの呼び出しに使用するアプリケーションとOAuth認証情報を管理できます。詳しくは、[Google Auth Platformを使ってみる](https://support.google.com/cloud/answer/15544987?hl=en)をご覧ください。

Google Auth Platformでは、次の操作を行えます。

* [Googleの同意画面を構成する](#configure-google-consent-screen)
* [Google OAuthクライアントを作成する](#create-google-oauth-client)
* [Google APIを有効にする](#enable-google-apis)

### Googleの同意画面を構成する

アプリケーションが機密性の高いOAuthスコープを要求する場合や、カスタム画像を使用する場合は、[OAuth同意画面の確認が完了するまで、Googleによってログインが100回に制限されます](https://developers.google.com/apps-script/guides/client-verification)。同意画面の確認には数日かかる場合があります。

OAuth 2.0を認可に使用する場合、アプリケーションはGoogleアカウントに対して1つ以上のアクセススコープの認可を要求します。Googleはユーザーに同意画面を表示し、プロジェクトの概要やポリシー、要求されたアクセススコープを提示します。

OAuthクライアントIDを作成する前に、アプリケーションの情報を入力してOAuth同意画面を構成しておく必要があります。

Google Cloud Consoleで、[Google OAuth同意画面を構成します](https://developers.google.com/workspace/guides/configure-oauth-consent)。

**1. 承認済みドメインを構成する**

**Google Auth Platform > Branding**に移動します。**Authorized domains**に
`auth0.com`と入力します。[カスタム
ドメイン](/docs/ja-jp/customize/custom-domains)を使用している場合は、代わりにそのカスタム
ドメインを入力します。

**2. オーディエンスを構成する**

**Google Auth Platform > Audience**に移動します。**User type**で
**Make External**を選択します。**Test Users**には、テストに使用する
メールアドレスを追加できます。

**3. データアクセスを構成する**

**Google Auth Platform > Data Access**に移動して、スコープを追加または削除します。
詳しくは、[OAuth 2.0 Scopes for Google
APIs](https://developers.google.com/identity/protocols/oauth2/scopes)を参照してください。

**4. 同意画面を構成する**

残りの手順に従って、[Google OAuth
同意
画面の構成](https://developers.google.com/workspace/guides/configure-oauth-consent)を完了します。

**5. 変更を保存する**

**Save Changes**を選択します。

### Google OAuthクライアントを作成する

Google Cloud Consoleで[新しいOAuth 2.0クライアントを作成](https://console.cloud.google.com/auth/clients/create)します。

**1. クライアントを作成する**

**Google Auth Platform > Clients**に移動し、**New Client**を選択します。

**2. アプリケーションの種類を選択する**

**Application type**で**Web application**を選択します。

**3. クライアント認証情報を構成する**

OAuth 2.0クライアントに以下の情報を入力します。

<ul>
  <li>**Name**：OAuth 2.0クライアントの名前</li>
  <li>**Authorized JavaScript origins**：`https://YOUR_AUTH0_DOMAIN`</li>

  <li>
    **Authorized redirect URIs**：`https://YOUR_AUTH0_DOMAIN/login/callback`
  </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**.

**4. 完了**

**Create**を選択します。

### Google API を有効にする

OAuth 2.0 クライアントで使用する Google API を有効にします。

**1. Google API ライブラリで検索する**

[Google API Library](https://console.cloud.google.com/apis/library) に移動し、使用する Google API を検索して、検索結果から選択します。

**2. Google API を有効にする**

有効にする Google API ごとに、**Enable** を選択します。

## Auth0 Dashboard

Auth0 Dashboardで、適切なOAuth認証情報を使用してGoogleのソーシャル接続を作成・構成します。

### Googleのソーシャル接続を作成する

[Auth0 Dashboard](https://manage.auth0.com/)で、新しいGoogleのソーシャル接続を作成します。

**1. 接続を作成する**

\*\*［Authentication (認証) ］>［Social (ソーシャル) ］**に移動します。**［Create Connection (接続の作成) ］\*\*を選択し、
\*\*［Google/Gmail］\*\*を選択します。

**2. クライアント認証情報を構成する**

\*\*［General (一般) ］\*\*で、作成したGoogle OAuth 2.0
クライアントのクライアント認証情報を入力します。

<ul>
  <li>**Client ID**：アプリケーションの一意の識別子です。</li>

  <li>
    **Client Secret**：アプリケーションがAuth0での認証に使用するシークレットです。
    詳細については、「[Client secret
    認証](/docs/ja-jp/secure/application-credentials#client-secret-authentication)」をお読みください。
  </li>
</ul>

**3. Connected Accounts for Token Vaultを有効にする**

\*\*［Purpose (用途) ］**で、**［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)」をお読みください。

**4. 権限を選択する**

\*\*［Permissions (権限) ］**で**［Offline Access (オフラインアクセス) ］\*\*を選択します。これにより、クライアントアプリケーションが外部プロバイダーからリフレッシュトークンを取得できるようになります。Googleのソーシャル接続で取得したアクセストークンには適切な
スコープが含まれるため、そのトークンを使って必要なGoogle APIを呼び出せます。

**5. アプリケーションを有効にする**

保存したら、\*\*［Applications (アプリケーション) ］\*\*タブに移動し、この接続を使用する
アプリケーションを選択します。

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

### 接続をテストする

Googleのソーシャル接続を作成したら、[接続をテストしてください](/docs/ja-jp/authenticate/identity-providers/test-connections)。

## Token Vaultの設定例

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

**JavaScript**

**Python**

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