> For the complete documentation index, see [llms.txt](https://developerdocs.instructure.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developerdocs.instructure.com/services/dap/query-api/oauth_login.md).

# Authentication

How to obtain and use the Access Token (JWT)

## 1. Get your ClientID and Secret <a href="#get-your-clientid-and-secret" id="get-your-clientid-and-secret"></a>

**If you are an Institution**: make sure that you have generated your ClientID and Secret for institutional use on the [Identity Service](https://identity.instructure.com/login/) page.

**If you are a Partner of Instructure**: make sure that you have received your ClientID and Secret from your Institution.

The tables a client can read are set when the client is registered, before you receive the ClientID and Secret. Each grant lists the tables per DAP namespace (see [Namespaces](/services/dap/dataset/dataset-namespaces.md)). To change the grant, ask for the registration to be updated.

{% hint style="info" %}
Keep your ClientID and Secret in a safe place! Do not share with anyone else!
{% endhint %}

## 2. Requesting the Access Token <a href="#requesting-the-access-token" id="requesting-the-access-token"></a>

Using the ClientID and Secret you are ready to request for an `access token`. The `access token` is a JSON Web Token, that grants access to the targeted Instructure service. This is a short lived token, it needs to be renewed periodically. Typically expires in one hour.

{% openapi src="/files/gncpadGJMP8LC0N3SQxd" path="/oauth/token" method="post" %}
[openapi.json](https://3935729257-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB0qnrcLHZo7GMoCVWI3W%2Fuploads%2Fgit-blob-63e3f5774831d53347c99b1fea429a38bdc8f25f%2Fopenapi.json?alt=media)
{% endopenapi %}

Request the token and call the services through the API Gateway endpoint for your region, it has to match your Canvas instance's region. The token endpoint is `/oauth/token` on that host.

| Region                   | API Gateway endpoint                                 |
| ------------------------ | ---------------------------------------------------- |
| `us-east-1` (`iad`)      | `https://us-east-1.api-gateway.instructure.com`      |
| `us-west-2` (`pdx`)      | `https://us-west-2.api-gateway.instructure.com`      |
| `ca-central-1` (`yul`)   | `https://ca-central-1.api-gateway.instructure.com`   |
| `eu-west-1` (`dub`)      | `https://eu-west-1.api-gateway.instructure.com`      |
| `eu-central-1` (`fra`)   | `https://eu-central-1.api-gateway.instructure.com`   |
| `ap-southeast-1` (`sin`) | `https://ap-southeast-1.api-gateway.instructure.com` |
| `ap-southeast-2` (`syd`) | `https://ap-southeast-2.api-gateway.instructure.com` |

The request takes these form parameters:

* `grant_type`: always `client_credentials`.
* `scope`: always `dap`.
* `authorization_details`: a JSON array with one entry of type `dap`. It names the tables the token is for. DAP needs it to return table data. A token without it carries no table grant.

| Field        | Description                                                                  |
| ------------ | ---------------------------------------------------------------------------- |
| `type`       | Always `"dap"`.                                                              |
| `namespaces` | Maps each DAP namespace to the list of table names. List each table by name. |

The available namespaces are listed in [Namespaces](/services/dap/dataset/dataset-namespaces.md):

| Namespace                                                                       | Description                                                                 |
| ------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [`canvas`](/services/dap/dataset/dataset-namespaces/dataset-canvas.md)          | Tables from Canvas                                                          |
| [`canvas_logs`](/services/dap/dataset/dataset-namespaces/dataset-canvaslogs.md) | Tables representing access logs                                             |
| [`catalog`](/services/dap/dataset/dataset-namespaces/dataset-catalog.md)        | Tables from Canvas Catalog. Requires a separate purchase of Canvas Catalog. |
| [`new_quizzes`](/services/dap/dataset/dataset-namespaces/dataset-newquizzes.md) | Tables from New Quizzes                                                     |

Example value:

```json
[{"type":"dap","namespaces":{"canvas":["courses","enrollments"]}}]
```

The token carries the identifier claims `partner_id`, `account_uuid` and `region`, plus `aud` set to the audience your client was registered with.

The following code snippet uses `curl` to send the request and `jq` to extract the `access token` from the answer:

```bash
ACCESS_TOKEN=$(curl --request POST https://us-east-1.api-gateway.instructure.com/oauth/token \
--user "${CLIENT_ID}:${SECRET}"  \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=dap' \
--data-urlencode 'authorization_details=[{"type":"dap","namespaces":{"canvas":["courses","enrollments"]}}]' | jq -r '.access_token')

echo $ACCESS_TOKEN
```

The response contains `"scope": "dap"`. The token carries the granted tables in its `authorization_details` claim. The legacy `/ids/auth/login` endpoint on the API Gateway returns `scope: SERVICE_ID principal:PRINCIPAL_ID partner:PARTNER_ID region:REGION_ID` instead.

## 3. Using the Access Token <a href="#example-using-the-access-token" id="example-using-the-access-token"></a>

Once you received the `access token` you can call the desired service. The example below will demonstrate this by querying the list of table names that exist in Canvas using the [DAP Query API](/services/dap/query-api/query-api-reference.md). The `access token` shall be passed as a bearer token in the Authorization header:

```bash
curl --request GET 'https://us-east-1.api-gateway.instructure.com/dap/query/canvas/table' \
--header "Authorization: Bearer ${ACCESS_TOKEN}" 
```

Upon success the call returns with a list of table names available Canvas.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developerdocs.instructure.com/services/dap/query-api/oauth_login.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
