> For the complete documentation index, see [llms.txt](https://docs.ox.security/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ox.security/ox-code/scanning/ox-cli-1/configuring-cloudflare-access-for-the-ox-cli.md).

# Configuring Cloudflare Access for the OX CLI

The OX CLI supports Cloudflare Access authentication through environment variables. If your organization routes CLI requests through Cloudflare Access, set the service token credentials before running scans so the requests include the required authentication headers.

## Prerequisites

Before configuring Cloudflare Access, make sure you have:

* The OX CLI installed.
* A Cloudflare Access service token with a client ID and client secret, provided by your organization's administrator.
* Access to the OX environment through your organization's Cloudflare Access configuration.

## Configuring Cloudflare Access for the OX CLI

Set the following environment variables before running the CLI:

| Environment variable      | Description                                    |
| ------------------------- | ---------------------------------------------- |
| `CF_ACCESS_CLIENT_ID`     | Cloudflare Access service token client ID.     |
| `CF_ACCESS_CLIENT_SECRET` | Cloudflare Access service token client secret. |

### Linux and macOS

To configure the credentials for the current terminal session:

1. Set the environment variables:

   ```
   export CF_ACCESS_CLIENT_ID="<client-id>"
   export CF_ACCESS_CLIENT_SECRET="<client-secret>"
   ```
2. Run your OX CLI scan from the same environment.

### Windows PowerShell

To configure the credentials for the current PowerShell session:

1. Set the environment variables:

   ```
   $env:CF_ACCESS_CLIENT_ID="<client-id>"
   $env:CF_ACCESS_CLIENT_SECRET="<client-secret>"
   ```
2. Run your OX CLI scan from the same PowerShell session.

## Removing CLI credentials

To remove the credentials from the current Linux or macOS shell session, run:

```
unset CF_ACCESS_CLIENT_ID
unset CF_ACCESS_CLIENT_SECRET
```

To remove the credentials from the current Windows PowerShell session, run:

```
Remove-Item Env:CF_ACCESS_CLIENT_ID
Remove-Item Env:CF_ACCESS_CLIENT_SECRET
```

## How Cloudflare Access authentication works

When the environment variables are configured, OX includes the following headers in requests to the OX backend:

| Header                    | Value                                   |
| ------------------------- | --------------------------------------- |
| `CF-Access-Client-Id`     | The value of `CF_ACCESS_CLIENT_ID`.     |
| `CF-Access-Client-Secret` | The value of `CF_ACCESS_CLIENT_SECRET`. |

Cloudflare Access validates these headers before allowing the request to reach OX.

## Troubleshooting

| Issue                                        | Possible cause                                                  | Recommended action                                                                |
| -------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| CLI scans fail behind Cloudflare Access.     | The environment variables are not available to the CLI process. | Set both variables in the environment where the CLI runs and retry the scan.      |
| Requests are rejected by Cloudflare Access.  | The client ID or client secret is missing or incorrect.         | Verify the credentials with your administrator and set the variables again.       |
| Requests fail after credentials are updated. | The environment contains outdated credentials.                  | Replace the values with the current service token credentials and retry the scan. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ox.security/ox-code/scanning/ox-cli-1/configuring-cloudflare-access-for-the-ox-cli.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
