# OvokConfig

Canonical page: https://docs.ovok.com/java-sdk/reference/ovok-config

```java
public final class OvokConfig
```

Settings for an [`Ovok`](/java-sdk/reference/ovok) client; build one with [`builder()`](#builder).

```java
OvokConfig config = OvokConfig.builder()
        .baseUrl("https://api.sandbox.ovok.com")
        .tenantCode("my-tenant")
        .clientId("my-client-id")
        .build();
Ovok ovok = new Ovok(config);
```

Set `clientSecret` too for a machine client; without it the client signs in users.

## Methods [#methods]

### builder [#builder]

```java
public static OvokConfig.Builder builder()
```

Starts a new configuration.

**Returns:** a builder with the defaults

## OvokConfig.Builder [#ovokconfigbuilder]

```java
public static final class Builder
```

Builds an `OvokConfig`. `baseUrl` and `tenantCode` are required.

### Builder.baseUrl [#builderbaseurl]

```java
public OvokConfig.Builder baseUrl(String value)
```

Sets the API base URL.

**Parameters:**

- `value`: an absolute http(s) URL

**Returns:** this builder

**Throws:**

- [`OvokConfigException`](/java-sdk/reference/ovok-config-exception): if the value is not a valid URI

```java
public OvokConfig.Builder baseUrl(URI value)
```

Sets the API base URL.

**Parameters:**

- `value`: an absolute http(s) URL

**Returns:** this builder

### Builder.tenantCode [#buildertenantcode]

```java
public OvokConfig.Builder tenantCode(String value)
```

Sets the tenant (project) code.

**Parameters:**

- `value`: the tenant code

**Returns:** this builder

### Builder.fhirPath [#builderfhirpath]

```java
public OvokConfig.Builder fhirPath(String value)
```

Sets the path of the FHIR API under the base URL; the default is `fhir`.

**Parameters:**

- `value`: the path, such as `fhir/R4`

**Returns:** this builder

### Builder.storage [#builderstorage]

```java
public OvokConfig.Builder storage(OvokStorage value)
```

Sets where the user session is stored; the default keeps it in memory.

**Parameters:**

- `value`: the storage

**Returns:** this builder

### Builder.clientId [#builderclientid]

```java
public OvokConfig.Builder clientId(String value)
```

Sets the OAuth client id.

**Parameters:**

- `value`: the client id

**Returns:** this builder

### Builder.clientSecret [#builderclientsecret]

```java
public OvokConfig.Builder clientSecret(String value)
```

Sets the OAuth client secret, which makes this a machine client using client credentials.

**Parameters:**

- `value`: the client secret; requires a client id

**Returns:** this builder

### Builder.transport [#buildertransport]

```java
public OvokConfig.Builder transport(HttpClient value)
```

Sets the HTTP client used for every request; the default is `HttpClient.newHttpClient()`.

**Parameters:**

- `value`: the HTTP client

**Returns:** this builder

### Builder.timeout [#buildertimeout]

```java
public OvokConfig.Builder timeout(Duration value)
```

Sets the default request timeout; the default is 30 seconds.

**Parameters:**

- `value`: a positive duration

**Returns:** this builder

### Builder.maxNetworkRetries [#buildermaxnetworkretries]

```java
public OvokConfig.Builder maxNetworkRetries(int value)
```

Sets how often a failed request is retried; the default is 2.

**Parameters:**

- `value`: the retry count, at least 0

**Returns:** this builder

### Builder.onUnauthenticated [#builderonunauthenticated]

```java
public OvokConfig.Builder onUnauthenticated(Consumer<UnauthenticatedReason> value)
```

Sets the callback run when the user session ends and the user must sign in again.

**Parameters:**

- `value`: the callback

**Returns:** this builder

### Builder.build [#builderbuild]

```java
public OvokConfig build()
```

Validates the settings and builds the configuration.

**Returns:** the configuration

**Throws:**

- [`OvokConfigException`](/java-sdk/reference/ovok-config-exception): if a setting is missing or invalid
