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

# Freshbooks

> AI agentをユーザーのFreshBooksアカウントに接続し、請求書の作成、経費の記録、クライアント情報の管理を行えるようにします。

AI agentをユーザーのFreshBooksアカウントに接続すると、請求書の作成・送信、領収書に基づく経費の記録、クライアント情報の管理が可能になります。

## FreshbooksをAuth0に接続する

**1. Freshbooksの設定**

1. [Freshbooks Developerアカウント](https://www.freshbooks.com/developers)のページにアクセスし、サインアップします。
2. [Freshbooks Developer Center](https://my.freshbooks.com/#/developer)で新しいアプリを作成します。
3. アプリの詳細を設定します。

   * **Application Name**を設定します。
   * **Redirect URI**に`https://YOUR_AUTH0_DOMAIN/login/callback`を設定します。

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

   FreshBooksでは、ローカル開発の場合を除き、リダイレクトURIにHTTPSを使用する必要があります。
4. 必要なスコープを選択します (例：`user:profile:read`、`user:clients:read`、`user:invoices:read`など) 。
5. **［Save (保存) ］**を選択し、**Client ID**と**Client Secret**をコピーします。

Freshbooksの設定について詳しくは、[Freshbooksでのログインに関するドキュメント](https://www.freshbooks.com/api/authentication)を参照してください。

**2. Auth0の設定**

<ol>
  <li>[Auth0 Dashboard](https://manage.auth0.com) で
  **認証 > ソーシャル**に移動します。</li>
  <li>**接続を作成**を選択し、**Freshbooks**を選択します。</li>
  <li>**続行**を選択します。</li>

  <li>
    **一般**で、次の操作を行います。

    <ol type="A">
      <li>Freshbooks OAuth アプリの**クライアント ID**と**クライアントシークレット**を入力します。</li>

      <li>
        **Attributes**で、アプリケーションに必要なスコープを選択します。
        これにより、認証（基本的なプロフィール情報へのアクセスなど）や API アクセス（プロバイダーの API への接続など）の際に、アプリケーションが Freshbooks に要求できる権限が決まります。

        Dropbox または Google のソーシャル
        接続では、Auth0 Dashboard で**オフラインアクセス**を選択し、
        クライアントアプリケーションが Auth0 のリフレッシュトークンを取得できるようにする必要があります。
      </li>

      <li>アプリケーションに必要な追加のスコープを
      **追加のスコープ**フィールドに追加します。</li>
    </ol>
  </li>

  <li>**目的**で、**Token Vault の接続済みアカウント**をオンにします。これにより、
  接続で外部 API のアクセストークンを取得し、安全に保存できます。詳細については
  [Token Vault の接続済みアカウント](/docs/secure/call-apis-on-users-behalf/token-vault/connected-accounts-for-token-vault)を参照してください。</li>
  <li>**作成**を選択します。</li>

  <li>
    作成後、**アプリケーション**ページにリダイレクトされます。
    この接続を有効にするアプリケーションを選択します。

    新しい Auth0 テナントでは、**デフォルトアプリ**を選択できます。
  </li>

  <li>Freshbooks のソーシャル接続を作成したら、アプリケーションで使用する前に、[接続をテスト](/docs/authenticate/identity-providers/test-connections)して設定が正しく機能することを確認してください。</li>
</ol>

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

## Token Vault の設定例

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

**JavaScript**

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

export const withFreshbooksConnection = auth0AI.withTokenVault({
  connection: "freshbooks",
  scopes: [
      // Token Vault に必要なスコープ
      "user:profile:read",
      // アプリ固有の任意のスコープ
      ...
  ],
  refreshToken: getAuth0RefreshToken(),
  authorizationParams: {
    prompt: "login",
  },
});
```

**Python**

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

with_freshbooks_connection = auth0_ai.with_token_vault(
    connection="freshbooks",
    scopes=[
        # Token Vault に必要なスコープ
        "user:profile:read",
        # アプリ固有の任意のスコープ
        ...
    ],
    refresh_token=get_auth0_refresh_token,
    authorization_params={
        "prompt": "login",
    },
)
```

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