> 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/scan-and-analyze-with-ox/scanning/ox-cli-1/authenticating-ox-cli/connect-ox-cli-with-oauth.md).

# Connect OX CLI with OAuth

OAuth provides a streamlined way to authenticate the OX CLI. Instead of creating and configuring an API key, you sign in with your OX account. After you authenticate, the CLI securely stores the authentication tokens and uses them for subsequent commands.

### Before you begin

Make sure that:

* The OX CLI is installed.
* You have access to an OX organization.

### Authenticate with OAuth

1. Configure the OX API endpoint.

   ```bash
   ox-cli config set api-host https://api.cloud.ox.security
   ```
2. Configure the CLI to use OAuth authentication.

   ```bash
   ox-cli config set api-key oauth
   ```

   This configures the CLI to authenticate using OAuth instead of an API key.
3. Start the OAuth sign-in flow.

   ```bash
   ox-cli login
   ```
4. Complete the authentication process.

   Your default browser opens automatically. Sign in to your OX account and complete the authentication flow.

   After authentication completes successfully, the CLI stores the OAuth tokens locally for future use. You don't need to sign in again until the tokens expire or you sign out.

### Sign out

**To remove the stored OAuth tokens:**

Run:

```bash
ox-cli logout
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ox.security/scan-and-analyze-with-ox/scanning/ox-cli-1/authenticating-ox-cli/connect-ox-cli-with-oauth.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
