# The consent page

> Users see what an app asks for and allow or deny it, the realm remembers their answer, and they can take it back at any time.

When an app asks for access to a user's account, the realm shows the user a consent page: which app, what it asks
for, and which account they're signed in as. The user allows or denies it. The realm remembers the answer, so they
aren't asked again for the same thing, and the user can see every app they allowed and take any of them back.

Consent matters most for your customers, who decide for themselves which apps may use their account. For your own
first-party apps, you can let trusted apps skip the page.

## Before you begin

- **Privilege:** none for the page itself, which every realm shows. Changing the realm's consent settings, an app's
  name or the page's wording needs `RealmOwner` in the realm.
- **Where:** the API.
- **An app registered in the realm,** with the name customers should see in `clientName`.

## How it works

The consent page is in the user's own language, and shows:

- the app, by its `clientName`, or its client ID when it has no name;
- each scope it asks for, by its label;
- the authorization details it asks for, each shown whole (see
  [Rich authorization requests](/workforce-identity/authorization/rich-authorization-requests/));
- the APIs the tokens will be for;
- who is signed in, so the user knows which account they're allowing.

**Allow** sends the user back to the app with a code; **Deny** sends them back with `access_denied`.

During a browser sign-in ([Authorization code with PKCE](/workforce-identity/applications/single-sign-on/authorization-code/)),
once the user is signed in, the realm decides whether it must ask. If it must, it sends the browser to the consent
page with a one-time consent challenge. The answer goes back with the challenge. If the app sent `prompt=none` and
the user would have to be asked, no page is shown, and the app is told `consent_required`.

### When the user is asked

| Situation | Asked? |
|---|---|
| The app asks for the first time | Yes |
| The app asks again, for no more than before | No, while the realm remembers consent |
| The app asks for more than before | Yes |
| The app asks for `offline_access`, access while the user is away | Always |
| The app sends `prompt=consent` | Always |
| The app asks for `authorization_details` | Always: only scopes are remembered |
| A public app whose return address another program on the device could claim | Always |
| A trusted app, where both the realm and the app allow skipping | No |

### Taking it back

Users see every app they allowed on their **Authorized Apps** page in the dashboard, or through the API, and remove
any of them. Removing an app ends its tokens for that user at once, and the next time it asks, the user is asked
again. See [Authorized apps](../../self-service/authorized-apps/).

## Set it up

Consent works with no set-up: every realm remembers what users allowed, and asks every app. To change that, as a realm
administrator with your session in `$CVYUH_SESSION` (see [Call the API](/develop/api/)), change the realm's
`oauth2Settings`:

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

### Say what each scope means

A scope with no label is shown by its name, which means little to a customer. Give each of your scopes a label, per
language, in the `oauth2` part of the realm's message bundle. Here `read:orders` in English and French:

```sh
curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/i18nBundle/i18nBundle \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
  -H "Content-Type: application/json" \
  -d '{ "bundles": {
      "oauth2": {
        "en": { "scope.read:orders": "See your orders" },
        "fr": { "scope.read:orders": "Voir vos commandes" }
      }
  } }'
```

A customer whose browser asks for French, signing in to **Example App** with `scope=openid read:orders`, then reads:

```text
Autoriser l'accès
Example App demande l'accès à votre compte.
  • Vous connecter
  • Voir vos commandes
Connecté en tant que Maya Chen
[Autoriser]  [Refuser]
```

In English the same page reads "Example App is asking to access your account", with "Sign you in" and "See your
orders".

The page's own lines (its title, the prompt, the buttons and "Signed in as") are messages too, under `consent.title`,
`consent.prompt`, `consent.allow`, `consent.deny` and `consent.signed.in.as`, and change the same way.

### Settings

| Where | Setting | What it does |
|---|---|---|
| `oauth2Settings` | `rememberConsent` (on) | Remember what users allowed |
| `oauth2Settings` | `consentSkipAllowed` (off) | Let trusted apps skip the page |
| `oauth2Settings` | `consentChallengeLifetimeSecs` (`600`) | How long the user has to sign in and answer |
| `oauth2Client` | `consentImplied` (off) | This app skips the page, where the realm allows it |
| `oauth2Client` | `clientName` | The name the page shows for the app |
| `i18nBundle` | `bundles.oauth2.<language>` | The labels for scopes (`scope.<name>`) and authorization-details types (`authorizationDetails.<type>`) |

## What the user sees when it fails

| What happened | What the user sees | What to do |
|---|---|---|
| The challenge ran out of time | "This request can no longer be answered. Return to the application and try again." | They start again from the app. Raise `consentChallengeLifetimeSecs` if customers often take longer |
| The page was answered already, or opened in another browser or session | The same message | They start again from the app |
| The user chose **Deny** | Your app's return address, with `error=access_denied` | Show a page in your app that says what the app can't do without it |
| The app sent `prompt=none` and consent was needed | Your app's return address, with `error=consent_required` | Send the user again without `prompt=none` |

## Limits and defaults

| Limit | Default | Range |
|---|---|---|
| Time to sign in and answer (`consentChallengeLifetimeSecs`) | 600 seconds | 60 to 3600 seconds |
| Answers per challenge | One | |
| Languages included | English, French, German | Add any language through the message bundle |
| Remembered consent | One record per user and app | Widened as the app asks for more |

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| The page shows the app's client ID | The client has no `clientName` | Set `clientName` on the app |
| The page shows a scope's raw name | The scope has no label in the user's language | Add `scope.<name>` for that language |
| A trusted app still shows the page | One of `consentSkipAllowed`, `consentImplied` is off, the app is public with a loopback or custom-scheme return address, or the request carries `offline_access`, `prompt=consent` or `authorization_details` | See [Show or skip the consent page](../../guides/consent-screen/) |
| Customers are asked at every sign-in | `rememberConsent` is off, or the app asks for `offline_access` | Turn `rememberConsent` on; `offline_access` is always asked |

## Audit records

An **Allow** writes or widens the user's `oauth2Consent` record, and the token that follows is a `TOKEN_ISSUED`
record on their [audit trail](/audit-reports/audit-trail/what-is-recorded/). A user taking an app back is an
`APP_TAKEN_BACK` record. Changes to `oauth2Settings`, a client or the message bundle are in
[Change history](/audit-reports/audit-trail/change-history/).

## Good to know

- **Only the user who is signing in can answer,** from the same session.
- **A challenge is answered once.**
- **The time covers signing in as well as answering.**
- **Labels are your own text.** A scope's label is the message `scope.<name>`, and an authorization-details type's is
  `authorizationDetails.<type>`, set per language as for
  [Pages in the user's language](/workforce-identity/authentication/languages/). English, French and German are
  included, with labels for `openid` and `offline_access`.
- **Page text has no links.** The wording you set is shown as text. A link to your terms or privacy policy can't be
  placed on the page; show them in your app before it sends the customer to sign in.

## Related

- [Show or skip the consent page](../../guides/consent-screen/): choose which apps ask.
- [Remember what users allowed](../../guides/remembered-consent/): how remembered consent behaves.
- [Let users remove apps they allowed](../../guides/people-remove-apps/): the Authorized Apps page.
- [Customer data and privacy requests](../customer-data-and-privacy/): consent records as proof of consent.
- [Authorization code with PKCE](/workforce-identity/applications/single-sign-on/authorization-code/): the
  sign-in that consent is part of.
