# Let users remove apps they allowed

> Each user's Authorized Apps page lists the apps they allowed, and removing one ends everything that app holds for them at once.

Users stay in control of which apps act for them. On their **Authorized Apps** page they see every app they allowed
and take any of them back, without asking a realm administrator. There's nothing for you to set: the page is in the
dashboard for every user. This guide shows what a user does, what a removal ends, and how an administrator stops an
app for everyone or for one user.

**Before you start:** the user has allowed at least one app through the consent page. Users need no privilege;
the administrator's steps at the end need `RealmOwner` in the realm.

## Remove an app

<Steps>

1. The user opens **Authorized Apps** in the dashboard. Each app they allowed is listed by name, with what they
   allowed it and whether that includes access while they're away.

   Through the API, with the user'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"
   ```

2. They choose **Revoke** on the app. Through the API:

   ```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`.

</Steps>

## What a removal ends

- **Every token at once.** The app's access tokens and refresh tokens for this user stop working at the realm, at
  introspection and at every gateway.
- **The consent record.** The next time the app asks, the user sees the consent page again. If they allow it then,
  the app's new tokens work at once.

## Check it worked

The app is gone from **Authorized Apps**, and a token it held answers inactive at introspection.

The realm writes an `APP_TAKEN_BACK` record on the user's [audit trail](../../../audit-reports/audit-trail/what-is-recorded/),
naming the app.

## Cut off an app for every user

A realm administrator who needs to stop an app for everyone deactivates its client instead, with an administrator's
session:

```sh
curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client/example-app \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
  -H "Content-Type: application/json" \
  -d '{ "status": "inactive" }'
```

Its tokens then read inactive at introspection. Send `"active"` to undo it.

## Remove one app for one user

A support agent asked to remove an app from one customer's account can delete that customer's consent record for the
app, as a realm administrator. Find it by the customer's id:

```sh
curl -G https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Consent \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
  --data-urlencode 'filter={"filter":{"field":"subjectId","op":"=","value":"<the user'\''s id>"}}'

curl -X DELETE https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Consent/<record id> \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
  -H "If-Match: *"
```

The app is gone from the user's list, and the next time it asks, they see the consent page again. This doesn't end
the tokens the app already holds for them, as the user's own **Revoke** does: those run until they expire. To end
them at once, ask the user to choose **Revoke** themselves.

## Related

- [Authorized apps](../../self-service/authorized-apps/): what the list holds, and what a removal ends.
- [Revoke tokens](../../../workforce-identity/applications/revoke-access/revocation/): how a token is revoked.
- [Let users remove agents](../../../workforce-identity/guides/agents/people-remove-agents/): the same control for
  agents.
