> For the complete documentation index, see [llms.txt](https://docs.elimity.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.elimity.com/reference-manual/v3.46.6/server-configuration/oauth2-endpoint-parameters-for-gateway-authentication.md).

# OAuth2 endpoint parameters for gateway authentication

The v3.42.0 release added a new configuration option to support customization of Elimity Insights' access token retrieval for gateway authentication. By default, assuming you provided a value for `gatewayOAuth2`, Elimity Insights will perform a basic OAuth2 client credentials flow. The `gatewayOAuth2.endpointParams` configuration option allows inclusion of additional parameters in the access token request. It should be a record mapping parameter names to [Expr](https://expr-lang.org/) programs that result in the respective parameter's value.

As an example we'll explain how this feature allows us to provide out-of-the-box gateway authentication to our SaaS customers. As detailed in [our documentation about gateway-based imports](/reference-manual/v3.46.6/advanced-topics/gateway-based-imports.md), we want to include `base_url`, `gateway_url` and `source_id` custom claims in the access tokens from our own OAuth2 server. To achieve this, we first need to make sure Elimity Insights provides the additional information in its token requests. For example, a token request from `https://example.elimity.com` for a gateway at `https://gateway.example.com` to import into a source with id `42` should look like this:

```http
POST /oauth/token HTTP/1.1
Host: auth.elimity.com
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&
client_id=example-client-id&
client_secret=example-client-secret&
audience=gateway&
base_url=https%3A%2F%2Fexample.elimity.com&
gateway_url=https%3A%2F%2Fgateway.example.com&
source_id=42
```

This corresponds to the following configuration for Elimity Insights:

| Configuration option                       | Value                                    |
| ------------------------------------------ | ---------------------------------------- |
| `gatewayOAuth2.clientId`                   | `"example-client-id"`                    |
| `gatewayOAuth2.clientSecret`               | `"example-client-secret"`                |
| `gatewayOAuth2.endpointParams.audience`    | `"'gateway'"`                            |
| `gatewayOAuth2.endpointParams.base_url`    | `"baseURL"`                              |
| `gatewayOAuth2.endpointParams.gateway_url` | `"gatewayURL"`                           |
| `gatewayOAuth2.endpointParams.source_id`   | `"sourceID"`                             |
| `gatewayOAuth2.tokenUrl`                   | `"https://auth.elimity.com/oauth/token"` |

Each value in the `gatewayOAuth2.endpointParams` record must be a valid [Expr](https://expr-lang.org/) program with result type `string`. Elimity Insights will inject the following variables:

| Variable     | Type     | Description                                         |
| ------------ | -------- | --------------------------------------------------- |
| `baseURL`    | `string` | Base URL of the Elimity Insights server             |
| `gatewayURL` | `string` | URL of the gateway to import data from              |
| `sourceID`   | `string` | Unique identifier of the source to import data into |


---

# 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.elimity.com/reference-manual/v3.46.6/server-configuration/oauth2-endpoint-parameters-for-gateway-authentication.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.
