# Apps and agents

> The OAuth 2.0 and OpenID Connect endpoints your apps, services and agents call on your realm's host, and the documents they discover them from.

Your apps, services and AI agents don't use an administrator's session. They call your realm as an OAuth 2.0
authorization server and an OpenID Connect provider, with credentials of their own, in the standard form any OAuth
library speaks. Point the library at your realm's issuer and it finds everything else.

The issuer is your realm's host followed by `/oauth2`:

```
https://foobar.cvyuh.com/oauth2
```

## Discovery

A client reads the realm's metadata once and takes every endpoint, signing algorithm and supported grant from it:

```sh
curl https://foobar.cvyuh.com/oauth2/.well-known/openid-configuration
```

Your realm publishes these documents under `/.well-known/`, each readable by anyone, with no credential:

| Document | Address | What it gives |
|---|---|---|
| OpenID Connect discovery | `https://foobar.cvyuh.com/oauth2/.well-known/openid-configuration` | The provider's metadata, while the realm offers `openid` |
| OAuth 2.0 authorization server metadata (RFC 8414) | `https://foobar.cvyuh.com/.well-known/oauth-authorization-server/oauth2` | The same metadata, for OAuth clients that don't use OpenID Connect |
| Shared Signals transmitter (OpenID SSF 1.0) | `https://foobar.cvyuh.com/.well-known/ssf-configuration/oauth2` | Where a receiver manages its stream of security events, while the realm transmits them |
| Policy decisions (OpenID AuthZEN 1.0) | `https://foobar.cvyuh.com/.well-known/authzen-configuration` | The decision and search endpoints an enforcement point calls |

A document for something the realm doesn't offer answers `404`. See
[Check what clients discover](../../platform/guides/what-clients-discover/) for what a developer needs from them.

## Endpoints

Every endpoint sits beneath the issuer. The metadata names them; this table is what each one is for.

| Method | Endpoint | What it does | Page |
|---|---|---|---|
| `GET`, `POST` | `https://foobar.cvyuh.com/oauth2/authorize` | Signs the user in in the browser and returns a code to the app | [Authorization code with PKCE](../../workforce-identity/applications/single-sign-on/authorization-code/) |
| `POST` | `https://foobar.cvyuh.com/oauth2/par` | Takes a sign-in request before the browser goes to `authorize` | [Pushed authorization requests](../../workforce-identity/applications/client-security/pushed-authorization-requests/) |
| `POST` | `https://foobar.cvyuh.com/oauth2/token` | Issues tokens, for every grant the realm allows | [Access tokens](../../workforce-identity/applications/tokens/access-tokens/) |
| `POST` | `https://foobar.cvyuh.com/oauth2/authorize-challenge` | Signs a user in from your own native app's screens | [First-party app sign-in](../../workforce-identity/applications/single-sign-on/first-party-apps/) |
| `POST` | `https://foobar.cvyuh.com/oauth2/device_authorization` | Starts a sign-in for a device with no usable browser | [Device authorization](../../workforce-identity/applications/single-sign-on/device-authorization/) |
| `GET`, `POST` | `https://foobar.cvyuh.com/oauth2/device` | The page where the user enters the device's code | [Device authorization](../../workforce-identity/applications/single-sign-on/device-authorization/) |
| `POST` | `https://foobar.cvyuh.com/oauth2/bc-authorize` | Asks a user to approve on their own device, for an app or agent that isn't in front of them | [Backchannel authentication](../../workforce-identity/agents/backchannel-authentication/) |
| `GET`, `POST` | `https://foobar.cvyuh.com/oauth2/userinfo` | The signed-in user's claims | [OpenID Connect sign-in](../../workforce-identity/applications/single-sign-on/openid-connect/) |
| `POST` | `https://foobar.cvyuh.com/oauth2/introspect` | Whether a token is active, and what it carries | [Introspection](../../workforce-identity/applications/revoke-access/introspection/) |
| `POST` | `https://foobar.cvyuh.com/oauth2/revoke` | Withdraws a token | [Revoke tokens](../../workforce-identity/applications/revoke-access/revocation/) |
| `GET` | `https://foobar.cvyuh.com/oauth2/status/{list}` | A token status list, for checking tokens offline | [Status lists](../../workforce-identity/applications/revoke-access/status-lists/) |
| `GET` | `https://foobar.cvyuh.com/oauth2/jwks` | The public keys the realm signs tokens with | [Signing keys](../../platform/keys/signing-keys/) |
| `POST` | `https://foobar.cvyuh.com/oauth2/register` | Registers a client, with a registration token an administrator issued | [Dynamic registration](../../workforce-identity/applications/registration/dynamic-registration/) |
| `GET`, `POST` | `https://foobar.cvyuh.com/oauth2/logout` | Signs the user out of the realm and returns to the app | [Logout](../../workforce-identity/applications/single-sign-on/logout/) |
| `GET`, `POST` | `https://foobar.cvyuh.com/oauth2/consent` | The page where the user allows an app what it asked for | [Consent](../../customer-identity/consent/) |
| `POST`, `GET`, `DELETE` | `https://foobar.cvyuh.com/oauth2/ssf/stream` | A receiver's stream of security events; with `ssf/status`, `ssf/subjects/add`, `ssf/subjects/remove` and `ssf/verify` beside it | [Send signals](../../workforce-identity/signals/shared-signals/) |

## Get a token

A service with no user involved asks for a token with its own credentials:

```sh
curl -X POST https://foobar.cvyuh.com/oauth2/token \
  -u "<client id>:<client secret>" \
  -d grant_type=client_credentials \
  -d scope=<scope>
```

```json
{ "access_token": "<token>", "token_type": "Bearer", "expires_in": 300, "scope": "<scope>" }
```

The realm's other grants go to the same endpoint:

| Grant | `grant_type` | For |
|---|---|---|
| Authorization code | `authorization_code` | An app signing a user in in the browser |
| Refresh token | `refresh_token` | Keeping an app signed in |
| Client credentials | `client_credentials` | A service calling another, with no user |
| Token exchange (RFC 8693) | `urn:ietf:params:oauth:grant-type:token-exchange` | An agent acting for a user, or a token swapped for another API |
| Device code (RFC 8628) | `urn:ietf:params:oauth:grant-type:device_code` | A TV or command-line tool |
| Backchannel authentication (CIBA) | `urn:openid:params:grant-type:ciba` | An approval asked of the user on their own device |
| JWT bearer (RFC 7523) | `urn:ietf:params:oauth:grant-type:jwt-bearer` | A trusted partner's statement about a user, turned into a token |
| Deferred | `urn:ietf:params:oauth:grant-type:deferred` | Collecting a token the realm held back for an owner's approval |

A realm allows a grant only where its settings and the client's registration both list it.

<Aside type="note" title="Agents are clients too">
  An AI agent gets its tokens from the same endpoints, as a client of its own with an owner and a risk class. To act
  for a user, it exchanges the user's token for one that names both of them. See
  [Register an agent](../../workforce-identity/guides/agents/register-an-agent/) and
  [Let an agent act for a user](../../workforce-identity/guides/agents/agent-acts-for-a-person/).
</Aside>

## Enforcement points

An enforcement point, such as the gateway in front of your API, calls the realm with a token of its own, carrying the
scope each call needs:

| Method | Endpoint | What it does |
|---|---|---|
| `POST` | `https://foobar.cvyuh.com/access/v1/evaluation` | One decision: may this subject do this action on this resource |
| `POST` | `https://foobar.cvyuh.com/access/v1/evaluations` | Several decisions in one call |
| `POST` | `https://foobar.cvyuh.com/access/v1/search/subject` | Who may do an action on a resource |
| `POST` | `https://foobar.cvyuh.com/access/v1/search/action` | What a subject may do on a resource |
| `GET` | `https://foobar.cvyuh.com/policies/v1/export` | The realm's policies, to decide locally |
| `GET` | `https://foobar.cvyuh.com/policies/v1/revocations` | What has been withdrawn since, for a gateway deciding locally |

See [Ask the realm](/gateway/decisions/ask-the-realm/) and [Decide locally](/gateway/decisions/decide-locally/).

## Related

<CardGrid>
  <LinkCard title="Sign users in to a web app" description="The first app most realms connect, end to end." href="../../workforce-identity/guides/sign-in-to-apps/sign-in-web-app/" />
  <LinkCard title="Let one service call another" description="Client credentials, with no user involved." href="../../workforce-identity/guides/services/service-to-service/" />
  <LinkCard title="Register an agent" description="An agent's own identity, with no secret to leak." href="../../workforce-identity/guides/agents/register-an-agent/" />
  <LinkCard title="Call the API" description="The administration APIs, and how a script gets a session." href="../api/" />
</CardGrid>
