---
title: "OAuth for apps"
summary: "Taskloader's OAuth 2.1 server for app builders: discovery, client metadata documents and registration, PKCE, resources, scopes, refresh and revocation."
updated: "2026-11-19"
url: "https://taskloader.com/docs/authentication/oauth"
---

> Documentation index: https://taskloader.com/llms.txt

# OAuth for apps

Taskloader's OAuth 2.1 server for app builders: discovery, client metadata documents and registration, PKCE, resources, scopes, refresh and revocation.

Use OAuth when people connect **your** app to **their** Taskloader account. This page is the reference for building such an app. For a working example, see [Build an OAuth app](https://taskloader.com/docs/guides/build-an-oauth-app.md). To connect an existing MCP client such as Claude or ChatGPT, see [MCP](https://taskloader.com/docs/mcp.md) instead: those clients do all of this for you.

## At a glance

|                       |                                                                                                                                                        |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Issuer                | `https://taskloader.com/api/auth`                                                                                                                      |
| Grant types           | `authorization_code` (with PKCE `S256`, required for every client) and `refresh_token`                                                                 |
| Client registration   | [Client ID metadata documents](#client-id-metadata-documents) (recommended), or [dynamic registration](#dynamic-client-registration) of public clients |
| Client authentication | `none` (public clients) or `private_key_jwt`. No client secrets.                                                                                       |
| Resources             | `https://taskloader.com/api/v1` (REST API) and `https://taskloader.com/mcp` (MCP server)                                                               |
| Access tokens         | Opaque, `tlo_at_…`, 1 hour                                                                                                                             |
| Refresh tokens        | Opaque, `tlo_rt_…`, rotated on every use, 30 days from each refresh; only with `offline_access`                                                        |
| Scopes                | The eleven [Taskloader scopes](https://taskloader.com/docs/scopes.md), plus `offline_access`                                                                                    |

## Discovery

Start from the resource you want to call. Its protected resource metadata (RFC 9728) names the authorization server:

| Resource                                 | Protected resource metadata                                          |
| ---------------------------------------- | -------------------------------------------------------------------- |
| REST API `https://taskloader.com/api/v1` | `https://taskloader.com/.well-known/oauth-protected-resource/api/v1` |
| MCP server `https://taskloader.com/mcp`  | `https://taskloader.com/.well-known/oauth-protected-resource/mcp`    |

```json
{
  "resource": "https://taskloader.com/api/v1",
  "authorization_servers": ["https://taskloader.com/api/auth"],
  "bearer_methods_supported": ["header"],
  "scopes_supported": [
    "projects:read",
    "projects:write",
    "tasks:read",
    "tasks:write",
    "comments:write",
    "files:read",
    "files:write",
    "people:manage",
    "organizations:manage",
    "assistant",
    "invitations:accept"
  ],
  "resource_name": "Taskloader",
  "resource_documentation": "https://taskloader.com/docs/api",
  "resource_policy_uri": "https://taskloader.com/privacy"
}
```

The MCP server's document is the same with `"resource": "https://taskloader.com/mcp"` and its own documentation link. Every `401` from the API carries the document's address in its challenge, as `resource_metadata`, so a client can discover it from any failed request.

The authorization server's metadata (RFC 8414) is at the issuer's well-known address, with the issuer path after `oauth-authorization-server`:

```text
https://taskloader.com/.well-known/oauth-authorization-server/api/auth
```

```json
{
  "issuer": "https://taskloader.com/api/auth",
  "authorization_endpoint": "https://taskloader.com/api/auth/oauth2/authorize",
  "token_endpoint": "https://taskloader.com/api/auth/oauth2/token",
  "registration_endpoint": "https://taskloader.com/api/auth/oauth2/register",
  "revocation_endpoint": "https://taskloader.com/api/auth/oauth2/revoke",
  "response_types_supported": ["code"],
  "response_modes_supported": ["query"],
  "grant_types_supported": ["authorization_code", "refresh_token"],
  "code_challenge_methods_supported": ["S256"],
  "token_endpoint_auth_methods_supported": ["none", "private_key_jwt"],
  "token_endpoint_auth_signing_alg_values_supported": [
    "RS256",
    "ES256",
    "EdDSA"
  ],
  "revocation_endpoint_auth_methods_supported": ["none", "private_key_jwt"],
  "client_id_metadata_document_supported": true,
  "authorization_response_iss_parameter_supported": true,
  "scopes_supported": [
    "projects:read",
    "projects:write",
    "tasks:read",
    "tasks:write",
    "comments:write",
    "files:read",
    "files:write",
    "people:manage",
    "organizations:manage",
    "assistant",
    "invitations:accept",
    "offline_access"
  ],
  "service_documentation": "https://taskloader.com/docs/authentication/oauth",
  "op_policy_uri": "https://taskloader.com/privacy",
  "op_tos_uri": "https://taskloader.com/terms"
}
```

Read these documents rather than hard-coding endpoints. Both are public, open to any origin and cacheable for 5 minutes.

> **Note:** Taskloader is not an OpenID Connect provider. `https://taskloader.com/.well-known/openid-configuration` and the root address `https://taskloader.com/.well-known/oauth-authorization-server` answer `404`. Use the path form above.

## Registering your app

There is no developer console and nothing to register by hand. Your app identifies itself in one of two ways.

### Client ID metadata documents

The recommended way. Your `client_id` is an HTTPS URL that serves a JSON document describing your app. Taskloader fetches it when someone connects, and shows its host on the consent screen as your verified identity: "An app at **sync.example.com** wants to use your Taskloader account".

```json
{
  "client_id": "https://sync.example.com/oauth/client-metadata.json",
  "client_name": "Northwind Sync",
  "client_uri": "https://sync.example.com",
  "redirect_uris": ["https://sync.example.com/oauth/callback"],
  "grant_types": ["authorization_code", "refresh_token"],
  "response_types": ["code"],
  "token_endpoint_auth_method": "none"
}
```

Rules:

- The `client_id` URL uses HTTPS on port 443, has a path, has no query or fragment, and is at most 512 characters.
- The document's `client_id` equals the URL it is served from, exactly.
- `client_name` is required.
- `token_endpoint_auth_method` is `none`, or `private_key_jwt` with a `jwks_uri` (see [Client authentication](#client-authentication)).
- `redirect_uris` are on the same origin as the `client_id`, or loopback addresses.
- `client_uri`, `jwks_uri` and `post_logout_redirect_uris` must be on the same origin as the `client_id`.
- `grant_types` includes `authorization_code`, or is left out. `refresh_token` may be listed beside it; other grant types Taskloader does not support are ignored.
- `response_types` is `["code"]`, or is left out.
- Member names and values are whole text: no NUL character (U+0000) and no character cut in half (a lone UTF-16 surrogate).
- `logo_uri`, `policy_uri` and `tos_uri` are never fetched or shown. People see your verified host, not a logo or a name you chose.
- Serve the document with `Content-Type: application/json` (a `charset` parameter is fine), at most 5 KB, from a public address, without redirects, within 5 seconds. A JSON body served as `text/plain`, as `application/octet-stream` or with no `Content-Type` is refused; some static hosts and object stores serve `.json` files that way, so check the header.
- Taskloader keeps a fetched document for at least 5 minutes and at most 1 hour: within that range, for as long as its HTTP cache headers allow. A document sent without cache headers, or with `no-cache`, `no-store`, `private` or a `max-age` under 300, is kept 5 minutes. A change therefore applies within an hour; while you are setting up, send `Cache-Control: no-store` (or `max-age=300`) so that changes apply within 5 minutes.
- A token or revocation request from an `https` `client_id` that never connected answers `401 invalid_client`: start with the authorization request.
- When too many new apps connect at once, the request stops on Taskloader's error page with `temporarily_unavailable`. Try again in a minute.

When the document breaks one of these rules, the person sees "Taskloader couldn't verify this app" instead of the consent screen, and nothing is shared. The page's address carries `error=invalid_client` and a `reason`, and the page explains that reason for you:

| `reason`             | What the page says                                                                                                                                                   |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `unreachable`        | Taskloader could not fetch the app's metadata document. Its client_id URL must answer 200 with JSON over HTTPS on port 443, from a public address, within 5 seconds. |
| `redirected`         | The app's metadata document URL answered with a redirect. Serve the document at the client_id URL itself: redirects are not followed.                                |
| `too_large`          | The app's metadata document is larger than 5 KB.                                                                                                                     |
| `not_json`           | The app's metadata document is not a JSON object served as application/json.                                                                                         |
| `client_id_mismatch` | The client_id in the app's metadata document is not exactly the URL it was fetched from.                                                                             |
| `client_name`        | The app's metadata document has no client_name.                                                                                                                      |
| `other_origin`       | A redirect URI, client_uri or jwks_uri in the app's metadata document is on another origin than its client_id. Only loopback redirect URIs may differ.               |
| `auth_method`        | The app's metadata document must use token_endpoint_auth_method none or private_key_jwt.                                                                             |
| `keys`               | For private_key_jwt, the app's metadata document needs valid public keys: jwks, or a jwks_uri on the client_id's origin.                                             |
| `redirect_uris`      | The app's metadata document needs redirect_uris: HTTPS URIs on the client_id's origin, or loopback URIs.                                                             |
| `links`              | A client_uri, logo_uri, policy_uri or tos_uri in the app's metadata document is not a valid public URL.                                                              |
| `grant_types`        | The app's metadata document lists grant_types without authorization_code. Include it, or leave grant_types out.                                                      |
| `response_types`     | The app's metadata document lists a response type other than code. Use "response_types": ["code"], or leave it out.                                                  |
| `forbidden_member`   | The app's metadata document contains a member it must not, such as client_secret.                                                                                    |
| `broken_text`        | The app's metadata document has a NUL character (U+0000) or a character cut in half (a lone UTF-16 surrogate) in a member name or value.                             |

Without a `reason`, Taskloader could not tell which rule the document broke: check it against the rules above.

### Dynamic client registration

For apps that cannot host a document, for example a desktop tool on a person's computer. Register a **public** client (RFC 7591), once, and keep the `client_id`:

```bash
curl https://taskloader.com/api/auth/oauth2/register \
  -H "Content-Type: application/json" \
  -d '{
    "client_name": "Northwind Sync",
    "application_type": "native",
    "redirect_uris": ["http://127.0.0.1/callback"],
    "grant_types": ["authorization_code", "refresh_token"],
    "response_types": ["code"],
    "token_endpoint_auth_method": "none"
  }'
```

The answer echoes your metadata with the `client_id` Taskloader assigned. There is no client secret.

Rules:

- `token_endpoint_auth_method` is `none`, or left out (then it is `none`). Any secret-based method is refused with `400 invalid_client_metadata`: "Taskloader registers public clients only: use token_endpoint_auth_method none with PKCE."
- `grant_types` contains `authorization_code`, and may add `refresh_token`; nothing else. Left out, it is `["authorization_code"]`. Any other list is refused with `400 invalid_client_metadata`: "grant_types may contain only authorization_code (required) and refresh_token."
- `response_types` is `["code"]`, or is left out. Anything else is refused with `400 invalid_client_metadata`: "response_types must be ["code"]."
- `application_type` is `native` or `web`. A `web` client registers only `https` redirect URIs on a public host. A loopback URI (`http://127.0.0.1`, `http://localhost`, `http://[::1]`) needs `native`, and a `native` client may list `https` and loopback URIs together, as VS Code and Cursor do. Without `application_type`, a registration with any loopback URI is `native`, otherwise `web`. A redirect URI that breaks these rules is refused with `400 invalid_redirect_uri`.
- Up to 5 `redirect_uris`.
- `client_name` is 1 to 60 characters (an emoji is one) on one line, needs a visible character, and must not look like a web address. Spaces around it are removed, and each run of spaces of any kind is stored as one. Line breaks, tabs, control characters, text-direction controls (U+202A to U+202E, U+2066 to U+2069) and other invisible characters (a zero-width space, a soft hyphen) are refused with `400 invalid_client_metadata`, which names the first one. What a name needs to show as written stays: joiners between characters (👩‍💻), the direction marks U+200E, U+200F and U+061C, and an emoji's presentation selector.
- `software_id` and `software_version`, when sent, are stored as sent and must be one line: no line breaks, tabs, control characters or text-direction controls.
- A redirect URI may not contain spaces or control characters. No member may hold a NUL character (U+0000) or half a character (a lone UTF-16 surrogate): such a registration is refused with `400 invalid_client_metadata` (`invalid_redirect_uri` when it is in `redirect_uris`).
- The JSON body can be up to 16 KiB.
- Registration is limited per network (an IPv4 address, or an IPv6 /48): at most 10 an hour, at most 5 at once. Over the limit, it answers `429 temporarily_unavailable` with `Retry-After`. Register once and store the `client_id`; do not register on every run.

Registered apps carry an **Unverified app** badge on the consent screen, and task history shows their name followed by "(unverified)", because anyone can register any name. Once a day, Taskloader deletes every registration that is more than a day old and that nobody has approved: either nobody approved it yet, or everyone who did has since disconnected it or reset their password. A registration unchanged for 90 days, with no tokens left and no approval given in that time, is deleted too. If you then get `invalid_client`, or the person sees "Taskloader couldn't verify this app" instead of the consent screen, register again and store the new `client_id`.

## Client authentication

| Method            | Use it when                                                                                   | How                                                                                                                                         |
| ----------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `none`            | Your app cannot keep a secret: desktop, mobile, browser, command line. Also fine for servers. | Send `client_id` with each token request. PKCE protects the code.                                                                           |
| `private_key_jwt` | Your server holds a private key and publishes a client metadata document.                     | Publish your public keys at `jwks_uri` (same origin as `client_id`). Send a signed client assertion with each token and revocation request. |

A `private_key_jwt` assertion is a JWT signed with `RS256`, `ES256` or `EdDSA`, with:

- `iss` and `sub`: your `client_id`;
- `aud`: the URL of the endpoint you call (`https://taskloader.com/api/auth/oauth2/token` for token requests, `https://taskloader.com/api/auth/oauth2/revoke` for revocation), or the issuer `https://taskloader.com/api/auth`, which both endpoints accept. Using the issuer lets one rule cover both;
- `exp`: at most 5 minutes in the future;
- `jti`: a unique value. Each assertion works once.

Send it as `client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer` and `client_assertion=<the JWT>`. PKCE is still required. If you also send `client_id`, it must be the same as `iss` and `sub`.

Never send an `Authorization` header to the token or revocation endpoint: Taskloader has no client secrets, and a request with `Authorization: Basic` is refused with `401 invalid_client` (and `WWW-Authenticate: Basic`), whatever else it carries. A request that names different clients in `client_id`, `iss` and `sub`, or whose `client_assertion` is not a readable JWT, is refused the same way.

Taskloader reads your `jwks_uri` when its copy is more than 5 minutes old, or when an assertion names a key id (`kid`) that copy does not have, but at most once a minute, whoever asks. To rotate keys, publish the new key at least a minute before you sign with it, and keep the old one published until you no longer sign with it.

## The authorization request

Send the person's browser to the authorization endpoint:

```text
https://taskloader.com/api/auth/oauth2/authorize
  ?response_type=code
  &client_id=https%3A%2F%2Fsync.example.com%2Foauth%2Fclient-metadata.json
  &redirect_uri=https%3A%2F%2Fsync.example.com%2Foauth%2Fcallback
  &scope=projects%3Aread%20tasks%3Aread%20tasks%3Awrite%20offline_access
  &state=Wv3nJ8qX2bYk
  &code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
  &code_challenge_method=S256
  &resource=https%3A%2F%2Ftaskloader.com%2Fapi%2Fv1
```

| Parameter                                 | Value                                                                                                                                                                                                                                                        |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `response_type`                           | `code`                                                                                                                                                                                                                                                       |
| `client_id`                               | Your metadata document URL, or the id from registration                                                                                                                                                                                                      |
| `redirect_uri`                            | One of your registered redirect URIs                                                                                                                                                                                                                         |
| `scope`                                   | Space-separated scopes. Add `offline_access` to get a refresh token.                                                                                                                                                                                         |
| `state`                                   | A random value you check in the callback                                                                                                                                                                                                                     |
| `code_challenge`, `code_challenge_method` | PKCE: `S256` only. `plain` or a missing challenge is refused. A challenge that is not 43 base64url characters (hex, or base64 with `+`, `/` or `=` padding) stops on Taskloader's error page with `error=invalid_code_challenge`, before the consent screen. |
| `resource`                                | `https://taskloader.com/api/v1` for the REST API. See [Resources](#resources).                                                                                                                                                                               |

### PKCE

Make a random `code_verifier` for every authorization: 43 to 128 characters from `A–Z`, `a–z`, `0–9`, `-`, `.`, `_` and `~`. The `code_challenge` is the base64url encoding, without padding, of its SHA-256 hash.

```curl
CODE_VERIFIER=$(openssl rand -base64 48 | tr '+/' '-_' | tr -d '=\n')
CODE_CHALLENGE=$(printf '%s' "$CODE_VERIFIER" | openssl dgst -sha256 -binary | openssl base64 -A | tr '+/' '-_' | tr -d '=')
```

```js
import { createHash, randomBytes } from 'node:crypto';

const codeVerifier = randomBytes(48).toString('base64url');
const codeChallenge = createHash('sha256').update(codeVerifier).digest('base64url');
```

```python
import base64, hashlib, secrets

code_verifier = secrets.token_urlsafe(48)
code_challenge = base64.urlsafe_b64encode(hashlib.sha256(code_verifier.encode()).digest()).rstrip(b"=").decode()
```

### Redirect URIs

- HTTPS redirect URIs must match a registered one exactly: scheme, host, port, path and query. No wildcards, fragments or user info.
- Loopback redirect URIs (`http://127.0.0.1`, `http://localhost`, `http://[::1]`) match on scheme, host and path, with **any port**. Register `http://127.0.0.1/callback` and listen on whatever port is free.
- Custom URI schemes (`myapp://callback`) are not accepted.
- A request with an unknown client, an unregistered redirect URI, an unknown `resource`, or no PKCE challenge, or a malformed one, never redirects. Taskloader shows the error on its own page, so a bad link cannot send people to an attacker.

### What the person sees

The consent screen shows:

- who is asking: your verified host for a metadata document, or "An app calling itself ‘…’" with an **Unverified app** badge for a registered client;
- where they will go next: the host of your `redirect_uri`. When this request returns to this computer (a loopback `redirect_uri`): "This app runs on your computer. Continue only if you started connecting it yourself.";
- the access you asked for, grouped as Read, Change and Manage, in plain words. Admin access (`people:manage`, `organizations:manage`) and `invitations:accept` start unticked; everything else starts ticked. The person can untick any scope, as long as one remains;
- **All my projects, including new ones**, or **Only these projects** (with Only these projects, `organizations:manage` and `invitations:accept` cannot be ticked: everything they allow acts outside any one project);
- how long: "Stays connected until you disconnect it, reset your password, or it goes 30 days without use" with `offline_access`, otherwise "Access ends after 1 hour".

People must confirm their email address, and have signed in within the last 24 hours, before they can approve an app (the consent screen offers **Sign in again**, which comes back to your request), and can have up to 50 connected apps (every app listed in Connected apps counts, whether it holds an approval or only a live token). Someone who signs up in the middle of your flow confirms their email first; if your authorization request expired meanwhile, start it again.

Taskloader skips the consent screen only when all of these are true: the app publishes a metadata document; at least one of its `redirect_uris` is not a loopback address; this request's `redirect_uri` is not a loopback address; and the person already approved every scope and resource requested. Registered (unverified) apps always see it.

### The callback

On **Allow**, the browser returns to your `redirect_uri`:

```text
https://sync.example.com/oauth/callback?code=…&state=Wv3nJ8qX2bYk&iss=https%3A%2F%2Ftaskloader.com%2Fapi%2Fauth
```

1. Check that `state` is the one you sent.
2. Check that `iss` is `https://taskloader.com/api/auth` (RFC 9207). Every response carries it, errors included, so an app that talks to several servers cannot be mixed up.
3. Exchange the `code` within 60 seconds. Codes work once; using one twice revokes the tokens it gave.

On **Cancel**, the callback gets `error=access_denied` with `state` and `iss`.

## The token request

The token endpoint takes `application/x-www-form-urlencoded` bodies only (anything else is `415`), answers with `Cache-Control: no-store`, and allows any origin, so browser apps can call it. Send each parameter once; only `resource` may repeat. A repeated parameter answers `invalid_request`, at the authorization, token and revocation endpoints alike. So does a parameter that holds a NUL character (U+0000).

```bash
curl https://taskloader.com/api/auth/oauth2/token \
  --data-urlencode grant_type=authorization_code \
  --data-urlencode code="$CODE" \
  --data-urlencode redirect_uri=https://sync.example.com/oauth/callback \
  --data-urlencode client_id=https://sync.example.com/oauth/client-metadata.json \
  --data-urlencode code_verifier="$CODE_VERIFIER" \
  --data-urlencode resource=https://taskloader.com/api/v1
```

```json
{
  "access_token": "tlo_at_…",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "tlo_rt_…",
  "scope": "projects:read tasks:read tasks:write offline_access"
}
```

`scope` lists what the person allowed, which can be less than you asked for. Store tokens like passwords: they are bearer credentials. Then call the API with `Authorization: Bearer tlo_at_…`.

### When the token endpoint refuses

Every answer from the token endpoint is JSON, with CORS and `Cache-Control: no-store`.

**A refused exchange can use up the code.** Taskloader first checks the request itself, and a refusal there leaves the code usable: a repeated parameter, a body that is not form-encoded (`415`), a missing `client_id` or `code`, an unknown `client_id` (`invalid_client`), and `429`. Then it uses up the code and checks it against the authorization (`client_id`, `redirect_uri`, `resource`, `code_verifier`). After a refusal there, fix the request and start the authorization again: sending the same code again answers `invalid_grant`.

The errors to handle:

| Answer                                                                                     | When                                                                                                                                                                                                                                                                                                                         | What to do                                                                                                                       |
| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `400 invalid_grant`                                                                        | The code expired (60 seconds), was used already (a refused exchange uses it up, see above), or does not match `redirect_uri`; the `code_verifier` is wrong; or a refresh token was rotated away, expired or revoked                                                                                                          | Start the authorization again                                                                                                    |
| `400 invalid_grant`, "code verification failed"                                            | The `code_verifier` does not match the `code_challenge`: the challenge must be the base64url encoding, without padding, of the SHA-256 of this verifier                                                                                                                                                                      | Fix how the challenge is made, then start the authorization again                                                                |
| `400 invalid_grant`, "Access for this app was withdrawn while this request was answered."  | During the code's 60 seconds, the person disconnected your app, or approved it again with fewer scopes than the code carries. Nothing the request issued stays alive.                                                                                                                                                        | Start the authorization again                                                                                                    |
| `400 invalid_grant`, "The refresh token was revoked while this request was answered."      | A password reset, **Disconnect** or detected reuse overtook the refresh                                                                                                                                                                                                                                                      | Start the authorization again                                                                                                    |
| `400 invalid_grant`, "This authorization could not be completed, and its code is used up." | The exchange failed after the code was used                                                                                                                                                                                                                                                                                  | Start the authorization again                                                                                                    |
| `400 invalid_client` (`401` for a metadata-document `client_id`)                           | Taskloader does not know the `client_id`: a registration that was deleted (`400`, "client not found"), or a metadata document that never connected (`401`); or a `private_key_jwt` assertion failed. Also `401` for an `Authorization: Basic` header, and for a `client_id` that differs from the assertion's `iss` or `sub` | Register again, start the authorization again, fix the assertion, or send no `Authorization` header                              |
| `400 invalid_request`, `invalid_target`                                                    | A parameter is missing, repeated or holds a NUL character (U+0000); or `resource` names one the authorization did not include (a refresh can ask only for resources the grant holds), or one Taskloader does not serve                                                                                                       | Fix the request. For a code, start the authorization again, unless a parameter was repeated or `client_id` or `code` was missing |
| `429 temporarily_unavailable`, with `Retry-After`                                          | Too many requests for this code or refresh-token family (30 a minute), or from your app at your address                                                                                                                                                                                                                      | Wait `Retry-After` seconds, then send the same request again. Nothing was issued or used up                                      |
| `500 server_error`, "Something went wrong. Please try again."                              | Anything else                                                                                                                                                                                                                                                                                                                | Safe to retry: send the same request again                                                                                       |

## Resources

Taskloader protects two resources, and every token is bound to the ones it was issued for:

| `resource`                      | For            |
| ------------------------------- | -------------- |
| `https://taskloader.com/api/v1` | The REST API   |
| `https://taskloader.com/mcp`    | The MCP server |

- **REST apps must send `resource=https://taskloader.com/api/v1`** on the authorization request. Without `resource`, Taskloader assumes an MCP client and issues an MCP token, which the REST API refuses with `401 invalid_token` and `reason: "wrong_audience"`.
- To use both, send `resource` twice on the authorization request. A token request may then ask for either or both; it can never add one that was not authorized.
- An unknown `resource` is refused with `invalid_target`.

## Scopes and offline_access

- Ask for the scopes your app needs, not all of them. Each one is a line the person reads before allowing. The [scope reference](https://taskloader.com/docs/scopes.md) says which operations each scope unlocks.
- `offline_access` asks for a refresh token. Without it, access ends when the access token expires after 1 hour.
- Check `scope` in the token response, or `credential.scopes` from `GET /api/v1/me`, to see what was granted. Hide features the person did not allow instead of letting them fail.
- A request that needs a scope the person did not grant fails with `403 insufficient_scope`, naming `requiredScopes`. To get more access, send the person through authorization again, asking for the extra scopes; Taskloader shows the consent screen for them.
- Approving again only adds what is newly allowed: the new token carries that approval's scopes, and earlier tokens keep theirs. If the person **unticks** a scope your app already had, every earlier token and outstanding code that carries it stops working at once (the API answers `401 invalid_token`, a refresh `invalid_grant`), while connections without that scope keep working.
- Account settings → Connected apps shows the person every scope your app can use: its approval, plus any scope a live token still carries.
- Your app always acts with the person's role in each project. Scopes narrow what it can do; they never add to the person's role.

## Refreshing tokens

```bash
curl https://taskloader.com/api/auth/oauth2/token \
  --data-urlencode grant_type=refresh_token \
  --data-urlencode refresh_token="$REFRESH_TOKEN" \
  --data-urlencode client_id=https://sync.example.com/oauth/client-metadata.json \
  --data-urlencode resource=https://taskloader.com/api/v1
```

- **Every refresh rotates.** The answer has a new access token and a **new refresh token**; store the new one before you use the access token. The old refresh token stops working.
- **Retries are safe for 60 seconds.** If the answer was lost, sending the identical refresh request again within 60 seconds returns the same answer. Identical refreshes sent at the same moment all get the same answer too, so parallel requests that all met a `401` cannot sign your app out.
- **Reuse after that is treated as theft.** Using an old refresh token later revokes the whole family: every refresh and access token from that sign-in. The token endpoint answers `invalid_grant`, and the person has to connect your app again.
- Refresh tokens last 30 days, counted from each refresh, so an app in regular use stays connected. A refresh never adds scopes or resources.
- Refresh before the access token expires (it lasts 1 hour), or when the API answers `401` with `reason: "expired"`.
- `private_key_jwt` clients send a fresh client assertion with every refresh, retries included.

If several processes share one connection, let one of them refresh and share the result. Two processes refreshing the same token more than 60 seconds apart revoke the family.

## Revoking tokens

When someone disconnects your app on your side, revoke its refresh token (RFC 7009):

```bash
curl https://taskloader.com/api/auth/oauth2/revoke \
  --data-urlencode token="$REFRESH_TOKEN" \
  --data-urlencode token_type_hint=refresh_token \
  --data-urlencode client_id=https://sync.example.com/oauth/client-metadata.json
```

Revoking a refresh token also revokes the access tokens issued from it, and a rotated (older) refresh token you present revokes its whole family too. Revoking an access token ends only that token. `token_type_hint` is only a hint: a refresh token sent with `token_type_hint=access_token` is revoked as a refresh token, and an access token sent as a refresh token is revoked too.

A revocation answers `200` with an empty body whether or not anything was left to revoke (RFC 7009). Revoking a token again, revoking one that has expired, sending a token your app never received (another app's tokens are never touched) and sending a value that is no Taskloader token all answer `200` and change nothing more. A retry after a lost answer is therefore always safe, and a `200` does not mean the token was valid. Only a request Taskloader cannot read is refused: without a `token` it answers `400 invalid_request`, and without a `client_id` `401 invalid_client`. It answers `401 invalid_client` too for an `Authorization: Basic` header, or a `client_id` that differs from your assertion's `iss` and `sub`.

Your app can also lose access without asking. Each of these takes effect on the next request:

| What happened                                                        | Effect                                                                                                                                                                                                                                                                                                |
| -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The person chose **Disconnect** in Account settings → Connected apps | Every token and the approval are deleted. Your app must ask again. If nobody else has approved your [registration](#dynamic-client-registration), the daily clean-up deletes it, usually within a day: register again when you get `invalid_client`.                                                  |
| The person reset their password                                      | Every token and every approval of every app is deleted. Your app gets new tokens only after the person approves it again on the consent screen; until then, their Connected apps lists it as signed out for a day or two. A registration nobody else has approved is deleted as after **Disconnect**. |
| The person approved your app again with fewer scopes                 | Every token and outstanding code carrying an unticked scope stops working.                                                                                                                                                                                                                            |
| The person removed a project from your app's list                    | That project answers `404` from then on.                                                                                                                                                                                                                                                              |
| The person left a project, or their role changed                     | Your app's access follows their membership and role.                                                                                                                                                                                                                                                  |

When a refresh answers `invalid_grant`, the connection is gone: stop, and offer to connect again.

## Lifetimes

| Item                           | Lifetime                                                                                                          |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
| Authorization code             | 60 seconds, single use                                                                                            |
| Access token                   | 1 hour                                                                                                            |
| Refresh token                  | 30 days from its issue; each refresh issues a new one                                                             |
| Identical refresh retry        | Answered the same for 60 seconds                                                                                  |
| Client metadata document cache | 5 minutes to 1 hour, as its cache headers allow within that range (5 minutes when they allow less or say nothing) |

## Limits on the OAuth endpoints

| Endpoint                  | Limit                                                                                                            |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Token endpoint            | 30 requests a minute per refresh-token family or authorization code, plus a high per-client, per-address ceiling |
| Registration              | At most 10 an hour per network, an IPv4 address or an IPv6 /48 (at most 5 at once), under a global flood ceiling |
| Consent (Allow or Cancel) | At most 60 an hour per person (at most 30 at once)                                                               |

Over a limit, the token, revocation and registration endpoints answer `429 temporarily_unavailable` with `Retry-After`: wait that many seconds, then send the same request again.

## Not supported

- OpenID Connect: no `openid` scope, ID tokens, userinfo or `openid-configuration`. `GET /api/v1/me` returns the person's name and email.
- Client secrets, and `client_secret_basic` or `client_secret_post`.
- The `client_credentials`, device, token exchange and JWT bearer grants.
- Token introspection. Call the API with the token instead: `GET /api/v1/me` tells you whether it works.
- Custom URI scheme redirects.
- DPoP and other proof-of-possession tokens.

The [status page](https://taskloader.com/docs/status.md) lists what is planned.
