> For the complete documentation index, see [llms.txt](https://docs.novacura.com/flow-connect/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.novacura.com/flow-connect/reference/how-to-guides/oidc-client-direct-calls/configure-your-application-for-client-direct-calls.md).

# Configure your application for Client Direct Calls

This page shows how to set up an application so that selected script steps run **on the client** and call a backend system directly, bypassing the Connector Agent.

For what the feature does and when it applies, see OIDC Client Direct Calls.

{% hint style="info" %}
Before you start, make sure the requirements are met: the client has direct network access to the backend, the endpoint is an HTTP endpoint configured for OpenID (OIDC) authentication, and the provider's `.well-known` configuration is reachable from the client. On the mobile clients (Android and iOS) this works directly; in the browser-based Web Client it additionally depends on the backend's CORS policy. See [OIDC Client Direct Calls](/flow-connect/reference/how-to-guides/oidc-client-direct-calls.md) for details.
{% endhint %}

### Create a module with OIDC configuration

Start by creating a module that stores the OpenID Connect configuration, so it can be shared across many script steps and applications.

Because the OIDC endpoint differs between environments, keep one configuration per environment and select the right one at runtime. Create a new module — name it `IFSCloudConnect` so it matches the examples below — and add this script with the values for your system.

```flowscript
/* Development */
private let baseUrlDev = "https://ifscloud-dev.example.com/"
private let oidcParamsDev: HTTP.OpenIDConnectParameters = {
    clientId: "flow-connect-client",
    scope: "openid",
    authority: "https://ifscloud-dev.example.com/auth/realms/dev",
    name: "IFS Cloud Client Side"
}

/* Test */
private let baseUrlTest = "https://ifscloud-test.example.com/"
private let oidcParamsTest: HTTP.OpenIDConnectParameters = {
    clientId: "flow-connect-client",
    scope: "openid",
    authority: "https://ifscloud-test.example.com/auth/realms/test",
    name: "IFS Cloud Client Side"
}

function getBaseUrl(environmentName: text): text {
    if environmentName == "Development":
        return baseUrlDev
    else if environmentName == "Test":
        return baseUrlTest
    else:
        error `Missing OIDC configuration for environment "{environmentName}".`
}

function getOidcConfig(environmentName: text): HTTP.OpenIDConnectParameters {
    if environmentName == "Development":
        return oidcParamsDev
    else if environmentName == "Test":
        return oidcParamsTest
    else:
        error `Missing OIDC configuration for environment "{environmentName}".`
}

function enableClientLogin(environmentName: text) {
    do ContextParams.set("OIDC", getOidcConfig(environmentName))
    do ContextParams.set("BaseURL", getBaseUrl(environmentName))
    return null
}
```

The per-environment configurations are `private`, so callers don't read them directly. Instead the module exposes three functions, each taking the current `environmentName`:

* `getOidcConfig(environmentName)` / `getBaseUrl(environmentName)` — use these when you build an HTTP request yourself (see below).
* `enableClientLogin(environmentName)` — call this to publish the OIDC configuration as **ContextParams**, which is how the generated OData modules pick it up when they execute. You only need it when you call those modules; for a raw `HTTP.request` you pass the result of `getOidcConfig` explicitly.

Add a new branch to `getBaseUrl` and `getOidcConfig` for each additional environment (e.g. `"Production"`); an unknown environment name raises a clear error rather than silently using the wrong endpoint.

{% hint style="info" %}
`environmentName` is automatically available in script steps, like a built-in environment variable — you don't need to declare or pass it. Just make sure the values it can hold match the names used in the `if` branches above (`"Development"`, `"Test"`, …).
{% endhint %}

### HTTP request in a script step

To run an HTTP request on the client, use the `RequestOptions` of the built-in [HTTP module](https://docs.novacura.com/flow-connect/reference/reference/flowscript/walkthrough/http-module). Resolve the OIDC configuration for the current environment from the `IFSCloudConnect` module and pass it as `authParameters` — that tells the client how to authenticate with the backend.

```flowscript
// Client-side execution
// `url`, `jsonBody` and `headers` are inputs to the step (`environmentName` is automatically available)
let oidcParams = IFSCloudConnect.getOidcConfig(environmentName)
let baseUrl = IFSCloudConnect.getBaseUrl(environmentName)
set url = baseUrl & url

let response = HTTP.request(
        url,
        {
            method: 'POST',
            body: jsonBody,
            headers: headers,
            authParameters: oidcParams,
            continueOnError: true
        }
    )

let success = response.statusCode >= 200 and response.statusCode <= 299;
if not success: error "The request failed with status code " & response.statusCode & " " & response.reasonPhrase;
return response.asText()
```

{% hint style="info" %}
The script step must be configured with **No connector**, so it runs on the client.
{% endhint %}

### IFS Cloud OData modules

The generated OData modules support both agent and client execution. Calling `enableClientLogin(environmentName)` publishes the OIDC context parameters for the current environment so the module can authenticate on the client.

To switch a step from running on the agent to running on the client, remove the connector (**No connector**) and add a single line of code:

```flowscript
open InventoryPartInStockHandling

do IFSCloudConnect.enableClientLogin(environmentName) // include OIDC context parameters

let parts = select *
            from InventoryPartInStockSet 
            where Contract = userDefaults.Contract
            and PartNo like partNoSearch

return parts
```


---

# 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.novacura.com/flow-connect/reference/how-to-guides/oidc-client-direct-calls/configure-your-application-for-client-direct-calls.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.
