> For the complete documentation index, see [llms.txt](https://docs.lenses.io/latest/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lenses.io/latest/devx/6.2/deployment/configuration/authentication/oauth.md).

# OAuth

HQ can act as an OAuth 2.0 Authorization Server (AS).

It is embedded -- no external AS is required. The implementation lives in internal/oauth2/ and follows the Authorization Code grant flow (RFC 6749 Section 4.1), with optional PKCE (RFC 7636) and support towards OAuth 2.1.

## Discovery and registration

1. Server Metadata (RFC 8414): Clients discover HQ's OAuth endpoints via GET /.well-known/oauth-authorization-server, which returns the issuer URL, endpoint URLs, supported grant types, scopes, token endpoint auth methods, and PKCE support.
2. Dynamic Client Registration (RFC 7591): When the dcr config flag is enabled, clients can self-register via POST /oauth2/register. DCR-created apps are placed into a configured default org. Each registered app receives a client\_id and client\_secret (bcrypt-hashed at rest).
3. Manual Registration: Apps can also be created via the HQ API (provenance "api" vs "dcr").

## Configuration

Add to the [HQ config](/latest/devx/6.2/deployment/configuration/hq.md#authconfig).

{% code overflow="wrap" %}

```
 auth:
    oauth2:
      authorizationServer:
        enabled: true
        issuerURL: "https://hq.example.com"
```

{% endcode %}

{% hint style="info" %}

```
  issuerURL is the only field that's conditionally required (when enabled is true)
```

{% endhint %}

For the full list of settings, see the [Configuration Reference](/latest/devx/6.2/deployment/configuration/hq/configuration-reference.md#authconfig-oauth).


---

# 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.lenses.io/latest/devx/6.2/deployment/configuration/authentication/oauth.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.
