> ## Documentation Index
> Fetch the complete documentation index at: https://www.1password.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Authorize your integrations using OAuth 2.0

> Learn how to manage OAuth 2.0 authorization for integrations with the 1Password Events API.

The 1Password Events API uses the [OAuth 2.0 client credentials flow](https://datatracker.ietf.org/doc/html/rfc6749#section-4.4) to authorize server-to-server integrations with 1Password Business or 1Password Enterprise Password Manager. Your integration uses its client credentials to obtain a short-lived, scoped access token when it needs to make a request.

## How OAuth 2.0 authorization works

Your integration authenticates to the OAuth token endpoint with its client ID and client secret to request an access token. It uses that token to authorize Events API requests. The main components of the authorization flow are:

| Component | Description |
| - | - |
| OAuth API endpoints | Your integration calls these endpoints to [request](https://www.1password.dev/users-api/request-access-token.md), [introspect](https://www.1password.dev/users-api/introspect-access-token.md), and [revoke](https://www.1password.dev/users-api/revoke-access-token.md) access tokens. |
| Events API resource servers | These servers host the [Retrieve audit events](https://www.1password.dev/events-api/v3/reference/retrieve-audit-events.md) endpoint, which validates the access token before returning events. |
| 1Password OAuth application | This application generates the client credentials and defines what the integration can access. |
| Integration (client) | Your application, service, or automation uses the client credentials to request an access token, then uses the token to call the Events API. |
| Client credentials | The client ID and client secret generated by the OAuth application. Your integration passes these to the token endpoint to request an access token. |
| Access token | The opaque bearer token returned by the token endpoint. It carries the application's scopes and expires after 15 minutes (900 seconds). Your integration sends it in the `Authorization` header when it calls the Events API. |

## Create an OAuth application in your 1Password account

Create an OAuth application in your 1Password account to get the client ID and client secret your integration uses to request an access token.

> [!NOTE]
>
> An OAuth application's scopes are set when you create it. If your integration needs different scopes, create a new application.

1. [Sign in](https://start.1password.com/signin) to your account on 1Password.com.

2. Select [**Integrations**](https://start.1password.com/integrations/directory) in the sidebar. If you've set up other integrations in your account, select **Directory** on the Integrations page.

3. Select **Events reporting**.

4. Select **Continue with OAuth**.

5. Configure your OAuth application:

   * **Application Name**: Enter a name to help you identify the integration.
   * **Scopes**: Check that **View audit events** is selected.
   * **Description**: (Optional) Add a description with additional information about your OAuth application.

   When you're finished, select **Next** to generate your client ID and client secret.

   > [!WARNING]
   >
   > 1Password shows the client secret once. Save it before you continue.

6. Select **Save in 1Password** and choose a vault for the client ID and client secret. Then select **View integration**.

When you select **Events reporting** in the directory, 1Password chooses the **Client credentials** grant type for you and marks that step as complete. If you select **Directory** > **OAuth Application**, choose **Client credentials** as the grant type, then select the **View audit events** scope.

You can now use your client ID and client secret to [request an access token](#request-an-access-token).

You can [rotate the client secret](#rotate-the-client-secret) of an existing application.

### Scopes

Select **View audit events** when you configure your OAuth application.

| Scope | Permission | Access level | Events API endpoints |
| - | - | - | - |
| `audit-events.view` | View audit events | Read | [Retrieve audit events](https://www.1password.dev/events-api/v3/reference/retrieve-audit-events.md), `GET /v3/accounts/{account}/audit-events` |

The scopes granted to an access token are listed in the `scope` field of the [token response](#receive-an-access-token). The Events API returns `403 Forbidden` if the token lacks the required scope or the request names a different account.

### Rotate the client secret

To replace your client secret, rotate it from the OAuth application in your 1Password account. 1Password shows the new client secret once. Save it before you continue. To keep your integration working, update the client secret in every tool that uses it, including your SIEM, before the previous secret expires.

If you need to disable the client credentials immediately, [revoke the OAuth application](#revoke-the-integration-in-your-1password-account) and create a new one.

## Request an access token

After you create the OAuth application and save the client credentials in your 1Password account, request an OAuth access token from the [token endpoint](https://www.1password.dev/users-api/request-access-token.md).

### Authorization endpoints

The OAuth API endpoints are hosted on the same base URL as the Events API. Use the base URL that matches the [region of your 1Password account](https://support.1password.com/regions/).

| Account domain | Base URL |
| - | - |
| 1Password.com | `https://api.1password.com` |
| 1Password.ca | `https://api.1password.ca` |
| 1Password.eu | `https://api.1password.eu` |
| ent.1password.com | `https://api.ent.1password.com` |

Access tokens are specific to the region they were issued in. Request the token from the same base URL that your integration uses for Events API requests.

Append the endpoint path to the base URL. Use `/v1/oauth/token` to [request an access token](https://www.1password.dev/users-api/request-access-token.md), `/v1/oauth/introspect` to [check whether a token is active](https://www.1password.dev/users-api/introspect-access-token.md), and `/v1/oauth/revoke` to [revoke a token](https://www.1password.dev/users-api/revoke-access-token.md).

### Token request headers and body parameters

Use the following request headers and body parameters to request an access token.

| Request element | Value | Required | Description |
| - | - | - | - |
| Header | `Authorization: Basic <encoded_client_credentials>` | When credentials are sent in the header | HTTP Basic authentication header that includes your base64-encoded client credentials. |
| Header | `Content-Type: application/x-www-form-urlencoded` | Yes | Indicates that the body contains URL-encoded form data. |
| Body parameter | `grant_type=client_credentials` | Yes | Specifies the OAuth 2.0 client credentials grant. |
| Body parameters | `client_id` and `client_secret` | When credentials are sent in the body | An alternative to the `Authorization` header. |

> [!NOTE]
>
> Every token request must include your client credentials. Choose one method per request. Send the credentials in the `Authorization` header (recommended) or as `client_id` and `client_secret` form fields.

Every access token is issued with the [scopes](#scopes) configured for the OAuth application.

### Example token request

Make a POST call to the [`/v1/oauth/token` endpoint](https://www.1password.dev/users-api/request-access-token). Include your client credentials, required headers, and request parameters.

> [tab] HTTP request
>
> If you use raw HTTP, base64-encode your OAuth client credentials before sending the request.
>
> 1. Join your client ID and client secret with a colon (`:`).
>
>    ```
>    <client_id>:<client_secret>
>    ```
>
> 2. Base64-encode the resulting string using your preferred tool. For example:
>
>    ```shell theme={null}
>    printf '%s' "<client_id>:<client_secret>" | base64
>    ```
>
> 3. Make a POST call to the [`/v1/oauth/token` endpoint](https://www.1password.dev/users-api/request-access-token). Replace `<encoded_client_credentials>` with the encoded string and set `Host` to your [regional API host](#authorization-endpoints).
>
>    ```http theme={null}
>    POST /v1/oauth/token HTTP/1.1
>    Host: api.1password.com
>    Content-Type: application/x-www-form-urlencoded
>    Authorization: Basic <encoded_client_credentials>
>
>    grant_type=client_credentials
>    ```

> [tab] Curl request
>
> Pass your client credentials in the `--user` option. Curl base64-encodes the credentials and sends them in the HTTP Basic authentication header.
>
> 1. Join your client ID and client secret with a colon (`:`).
>
>    ```
>    <client_id>:<client_secret>
>    ```
>
> 2. Make a POST call to the [`/v1/oauth/token` endpoint](https://www.1password.dev/users-api/request-access-token). Include the unencoded credentials in the `--user` option and use the [base URL for your account's region](#authorization-endpoints). For example:
>
>    ```shell theme={null}
>    curl --request POST https://api.1password.com/v1/oauth/token \
>      --header "Content-Type: application/x-www-form-urlencoded" \
>      --user "<client_id>:<client_secret>" \
>      --data "grant_type=client_credentials"
>    ```

## Receive an access token

A successful response includes the access token, its lifetime in seconds, and its scopes.

```json theme={null}
{
  "access_token": "<access_token>",
  "token_type": "Bearer",
  "expires_in": 900,
  "scope": "audit-events.view"
}
```

Access tokens expire after 15 minutes (900 seconds). Use the same client credentials to request a new access token when the current one expires.

The client credentials grant issues access tokens only. Token and introspection responses include the `Cache-Control: no-store` and `Pragma: no-cache` headers.

### Use the access token with the Events API

Use your access token in the `Authorization` header to authorize a request to the Events API. Replace `<access_token>` with the token you received. The `-` in the path selects the account associated with that token.

```shell theme={null}
curl --request GET \
  --url "https://api.1password.com/v3/accounts/-/audit-events" \
  --header "Authorization: Bearer <access_token>" \
  --header "User-Agent: <CompanyOrProductName>/<version>"
```

See [API conventions](https://www.1password.dev/events-api/v3/conventions.md#endpoint-paths) for account selection and [error responses](https://www.1password.dev/events-api/v3/conventions.md#errors).

### Check whether an access token is active

If your integration stores access tokens between tasks, you can call the [`/v1/oauth/introspect` endpoint](https://www.1password.dev/users-api/introspect-access-token) with your client credentials to check whether a token is active. The response includes the token's scopes and expiry time, or `"active": false` if the token has expired or been revoked.

## Revoke an access token

You can revoke a token when it's no longer needed using the OAuth revoke endpoint. You can also revoke all tokens for an integration by revoking the OAuth application in your 1Password account.

### Use the revoke endpoint

Use the [`/v1/oauth/revoke` endpoint](https://www.1password.dev/users-api/revoke-access-token) to revoke a token. Authenticate with the client credentials of the OAuth application that requested the token. For example:

```shell theme={null}
curl --request POST "https://api.1password.com/v1/oauth/revoke" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --user "<client_id>:<client_secret>" \
  --data "token=<ACCESS_TOKEN_TO_REVOKE>"
```

A successful revocation request returns `200 OK` with an empty body. The endpoint also returns `200 OK` if the submitted token was already expired, revoked, or unknown.

### Revoke the integration in your 1Password account

Revoke the OAuth application to disable its client credentials and revoke its access tokens.

1. [Sign in](https://start.1password.com/signin) to your account on 1Password.com.
2. Select [**Integrations**](https://start.1password.com/integrations/) in the sidebar.
3. Select the OAuth application for your integration.
4. Select **Revoke integration**, follow the confirmation instructions, then select **Revoke integration** again.

### Delete your integration's client

When you remove an integration from your own platform, also revoke its OAuth application in 1Password to disable its credentials and tokens.


## Related topics

- [Request an access token](https://www.1password.dev/users-api/request-access-token.md)
- [API conventions](https://www.1password.dev/events-api/v3/conventions.md)
- [Retrieve audit events](https://www.1password.dev/events-api/v3/reference/retrieve-audit-events.md)
- [Authorize your integrations using OAuth 2.0](https://www.1password.dev/users-api/authorization.md)
