# Authorized apps

> Each customer sees every app they allowed, with what it may do, and removes any of them, ending everything it holds for them at once.

Every app a customer allowed is on their **Authorized Apps** page: its name, what they allowed it, when, and whether
it may act while they're away. One choice of **Revoke** takes it back: the app's tokens for that customer stop
working at once, and the next time it asks, the customer sees the consent page again.

## Before you begin

- **Privilege:** none. Customers list and remove their own apps with their own session. Removing an app for every
  customer needs `RealmOwner` in the realm.
- **Where:** the dashboard's **Authorized Apps** page, or the API.
- **An app the customer allowed** on the consent page.

## How it works

The list comes from the realm's consent records, one per customer and app. Each entry carries:

| Field | What it holds |
|---|---|
| `clientId` | The app's client ID |
| `clientName` | The name the consent page shows, when the app has one |
| `scopes` | What the customer allowed it |
| `firstGranted`, `lastGranted` | When they first allowed it, and when they last did |
| `offline` | Whether it may act while they're away (`offline_access`), which removing it also ends |

Removing an app ends:

- **every token at once:** its access tokens and refresh tokens for this customer stop working at the realm, at
  introspection and at every gateway;
- **the consent record:** the next time the app asks, the customer is asked again. If they allow it then, the app's
  new tokens work at once.


## Set it up

There's nothing to set up: the page is in the dashboard for every user. Through the API, with the customer's own
session in `$CVYUH_SESSION` (see [Call the API](../../../develop/api/)):

```sh
curl https://foobar.cvyuh.com/api/v0/am/me/v1/oauth2/apps \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

```json
[
  { "clientId": "example-app", "clientName": "Example App", "scopes": ["openid", "profile", "email"],
    "firstGranted": "<RFC 3339 time>", "lastGranted": "<RFC 3339 time>", "offline": false }
]
```

Remove one:

```sh
curl -X DELETE https://foobar.cvyuh.com/api/v0/am/me/v1/oauth2/apps/example-app \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

The realm answers `204`, or `404` if the customer never allowed that app.

## What customers see

Each app by its name, what they allowed it, when they first and last allowed it, and whether it may act while
they're away, with a **Revoke** button. After **Revoke**, the app leaves the list, and the app itself finds its
tokens refused and must send the customer to sign in again, where the consent page asks afresh.

| Answer | Why | What to do |
|---|---|---|
| `204` | The app was taken back | Nothing |
| `404` | The customer never allowed that app, or already took it back | Nothing to take back |
| `401` | No session, or a session of another realm | Sign in to the customer realm first |

## Limits and defaults

- **One entry per app,** however many times the customer allowed it.
- **No paging:** the list holds every app the customer allowed.

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| An app allowed a few seconds ago is missing | The list can lag by a moment | Wait and reload. The realm still remembers the app, so the customer isn't asked again |
| An app keeps working after **Revoke** | An API checks the app's access tokens on its own, without introspection | Have the API introspect, or keep access tokens short; the realm already refuses them |
| A customer wants an app gone and can't sign in | They need a session to use the page | A realm administrator can remove the consent record for them; see [Let users remove apps they allowed](../../guides/people-remove-apps/#remove-one-app-for-one-user) |

## Audit records

Each **Revoke** writes an `APP_TAKEN_BACK` record on the customer's
[audit trail](/audit-reports/audit-trail/what-is-recorded/), naming the app.

## Good to know

- **Only their own.** These calls act on the signed-in customer's apps, never another's.
- **To stop an app for every customer,** a realm administrator deactivates its client instead; see
  [Let users remove apps they allowed](../../guides/people-remove-apps/).

## Related

- [The consent page](../../consent/consent-page/): how an app gets on the list.
- [Let users remove apps they allowed](../../guides/people-remove-apps/): the task, start to finish.
- [Revoke tokens](../../../workforce-identity/applications/revoke-access/revocation/): how a token is revoked.
