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

# Authentication

> All requests to the Connect AI API must be properly authenticated using either Basic Authentication or OAuth 2.0 Client Credentials.

## Basic Authentication

To authenticate a request using Basic Authentication, pass the Base64-encoded login credentials of a registered user in the `Authorization` header of the request. Follow this guidance when passing the credentials:

* The username is the email address of the user, e.g. `user@cdata.com`.
* The password is a Personal Access Token (PAT) that you generate from the [Settings](/ja/Settings#personal-access-tokens) page.
* If your application or service does not automatically Base64-encode the string, follow these steps to encode it manually:
  * Separate the username and PAT with a colon, for example, `user@cdata.com:token`.
  * Use Base64 to encode the colon-separated string.

The following is an example of a curl command that calls the API to return results from a Salesforce Account table:

```bash theme={null}
curl -X POST https://cloud.cdata.com/api/query
   -H "Content-Type: application/json"
   -d '{"query":"SELECT * FROM Salesforce1.Salesforce.Account LIMIT 10"}'
   --user "user@cdata.com:123456789abcdefghijklmnopqrstuvwxyz"
```

Since curl automatically Base64-encodes basic authentication credentials, it is not necessary to manually perform this encoding before sending the request.

## OAuth 2.0 Client Credentials

サービスアカウントは OAuth 2.0 Client Credentials フローで認証されます。この方式は、人間のユーザーを介さずにスクリプト、ジョブ、外部サービスを認証する場合に使用します。事前にサービスアカウントを作成し、[Users](/ja/Users#service-accounts) ページから **Client Id** と **Client Secret** をコピーしておく必要があります。

**Step 1: ベアラートークンをリクエストする**

```bash theme={null}
curl -X POST https://cloud-login.cdata.com/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials&client_id=<ClientId>&client_secret=<ClientSecret>"
```

レスポンスには `access_token` の値が含まれます。

**Step 2: Connect AI API を呼び出す**

以降のリクエストでは、トークンを Bearer 認証情報として渡します。例えば、クエリを実行する場合：

```bash theme={null}
curl -X POST https://cloud.cdata.com/api/query \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{"query":"SELECT * FROM Salesforce1.Salesforce.Account LIMIT 10"}'
```

OAuth 構成フィールドの入力を求められる統合（Databricks MCP Marketplace など）では、以下の値を使用します：

| フィールド                 | 値                                                                                      |
| :-------------------- | :------------------------------------------------------------------------------------- |
| **Token URL**         | [https://cloud-login.cdata.com/oauth/token](https://cloud-login.cdata.com/oauth/token) |
| **Authorization URL** | [https://cloud-login.cdata.com/authorize](https://cloud-login.cdata.com/authorize)     |
| **Client Id**         | サービスアカウントの Client Id                                                                   |
| **Client Secret**     | サービスアカウントの Client Secret                                                               |
