# OAuth apps

> Let people connect your app to their Folio account, with the permissions they approve.

Source: https://folio.hippodev.app/docs/oauth

Build an integration — a job board, a portfolio site, a career-coaching tool — that works with **other people's** Folio accounts. Instead of asking for an API key, your app sends people to Folio to sign in and approve what it may do, and gets an access token for the [API](https://folio.hippodev.app/docs/api). They can disconnect it any time in **Account → Security**.

## Register your app

In **Account → OAuth apps**, choose **Register app**:

* **Web app** — your server keeps a **client secret**. Redirect URIs must be `https://` on a real host.
* **Native or local app** — desktop, mobile, command-line, or local tools. There's no secret; you use **PKCE**. Redirect URIs are `http://` on `localhost`, `127.0.0.1`, or `[::1]` (any port), or a reverse-domain custom scheme like `com.example.app:/callback`.

A web app's client secret is shown once; **New secret** replaces it.

## Endpoints

|              |                                                                     |
| ------------ | ------------------------------------------------------------------- |
| Authorize    | `https://folio.hippodev.app/api/auth/oauth2/authorize`              |
| Token        | `https://folio.hippodev.app/api/auth/oauth2/token`                  |
| Discovery    | `https://folio.hippodev.app/.well-known/oauth-authorization-server` |
| API resource | `https://folio.hippodev.app/api/v1`                                 |

## Scopes

| Scope                      | Lets your app                                                      |
| -------------------------- | ------------------------------------------------------------------ |
| `resumes:read`             | Read resumes, cover letters, and templates                         |
| `resumes:write`            | Create, edit, publish, and delete them                             |
| `exports:create`           | Download files (JSON, text, Markdown, Word)                        |
| `domains:manage`           | Connect and remove custom domains                                  |
| `analytics:read`           | Read view statistics                                               |
| `applications:read`        | Read your job applications, their timelines, and stats             |
| `applications:write`       | Add, update, and delete job applications, notes, and logged emails |
| `inbox:read`               | Read, mark, and delete contact-form messages                       |
| `sharing:manage`           | Manage private links, collaborators, and the share link            |
| `webhooks:manage`          | Manage webhook endpoints                                           |
| `openid` `profile` `email` | Know who connected (name and email)                                |
| `offline_access`           | Get a refresh token, to stay connected                             |

Writing through the API needs the person to be on Pro, as with API keys.

## The flow

Folio uses the **authorization code** flow with **PKCE** (required for every app):

1. Make a random `code_verifier`, and its `code_challenge` (base64url SHA-256).
2. Send the person to the authorize endpoint:

```text
https://folio.hippodev.app/api/auth/oauth2/authorize
  ?response_type=code
  &client_id=YOUR_CLIENT_ID
  &redirect_uri=https://example.com/auth/folio/callback
  &scope=openid resumes:read offline_access
  &state=RANDOM_STATE
  &code_challenge=CODE_CHALLENGE
  &code_challenge_method=S256
  &resource=https://folio.hippodev.app/api/v1
```

3. They sign in and see what your app asks for. If they allow it, Folio redirects to your `redirect_uri` with `code` and your `state` — check that `state` matches.
4. Exchange the code at the token endpoint (a `POST` form). Web apps authenticate with their client ID and secret (HTTP Basic); native apps send `client_id` in the form:

```bash
curl -X POST https://folio.hippodev.app/api/auth/oauth2/token \
  -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \
  -d grant_type=authorization_code \
  -d code=THE_CODE \
  -d redirect_uri=https://example.com/auth/folio/callback \
  -d code_verifier=CODE_VERIFIER \
  -d resource=https://folio.hippodev.app/api/v1
```

5. Call the API with the access token:

```bash
curl https://folio.hippodev.app/api/v1/resumes \
  -H "Authorization: Bearer ACCESS_TOKEN"
```

Access tokens last an hour. With `offline_access`, refresh them with `grant_type=refresh_token`.

## Good to know

* Always send `resource=https://folio.hippodev.app/api/v1` — tokens for other resources don't work on the API.
* A code works once and expires in minutes.
* When someone disconnects your app, its tokens stop working immediately (`401` with `invalid_token`).
* OAuth requests are limited to 120 a minute per person and app.
* Want people's resume events pushed to you? Combine with [webhooks](https://folio.hippodev.app/docs/webhooks) on your own account, or poll the API.
