---
title: Authentication
slug: devicepark/sdk-documentation/getting-started/authentication
description: Configure OAuth2 client credentials and SDK client lifetime.
docTags: 
createdAt: 2026-08-10T08:03:45.197Z
---

Use the OAuth2 client credentials supplied by your Device Park administrator. Create the client once before calling other SDK methods and reuse it during the test run.

## Before You Begin

Set the credentials as environment variables:

```bash
export DEVICEPARK_CLIENT_ID=your-client-id
export DEVICEPARK_CLIENT_SECRET=your-client-secret
```

:::hint{type="warning"}
Keep `clientSecret` outside source control, CI output and application logs. Load credentials from your secret manager or environment.
:::

The SDK base URL is `https://devicepark.testinium.io` in the examples below. Credentials are the only secret values; the URL is not read from an environment variable by SDK version `1.0.1`.

## Create the Client

Create one client for the test run and close it during cleanup. Choose your SDK language:

:::CodeblockTabs
```java
import io.testinium.devicepark.DeviceParkApiClient;
import io.testinium.devicepark.authentication.credentials.Credentials;

try (DeviceParkApiClient client = DeviceParkApiClient.builder()
        .url("https://devicepark.testinium.io")
        .credentials(Credentials.of(
                System.getenv("DEVICEPARK_CLIENT_ID"),
                System.getenv("DEVICEPARK_CLIENT_SECRET")))
        .timeout(30)
        .build()) {

    // Call SDK methods with this client.
}
```

```typescript
import { Credentials, DeviceParkApiClient } from "@device-park/public-sdk";

const client = DeviceParkApiClient.builder()
  .url("https://devicepark.testinium.io")
  .credentials(Credentials.fromEnvironment())
  .timeout(30)
  .build();

try {
  // Call SDK methods with this client.
} finally {
  await client.close();
}
```

```csharp
using Testinium.DevicePark;

using var client = DeviceParkApiClient.Builder()
    .Url("https://devicepark.testinium.io")
    .Credentials(Credentials.FromEnvironment())
    .Timeout(30)
    .Build();

// Call SDK methods with this client.
```
:::

Java uses `Credentials.of(...)`. Node.js and .NET expose `Credentials.fromEnvironment()` / `Credentials.FromEnvironment()`, which read `DEVICEPARK_CLIENT_ID` and `DEVICEPARK_CLIENT_SECRET`. Java has no environment-variable factory; read the variables yourself and pass them to `Credentials.of(...)`.

In Node.js, credentials already available in application configuration can be passed with `Credentials.create(clientId, clientSecret)` or `.credentialsFrom(clientId, clientSecret)`. In .NET the equivalent is `Credentials.Of(clientId, clientSecret)`.

The .NET client implements `IDisposable`, so a `using` declaration releases it. There is no close method.

## Configuration

| Value          | Required | Java                  | Node.js                                  | .NET                                 |
| -------------- | -------- | --------------------- | ---------------------------------------- | ------------------------------------ |
| `url`          | Yes      | `.url(...)`           | `.url(...)`                              | `.Url(...)`                          |
| `clientId`     | Yes      | `Credentials.of(...)` | Environment or `Credentials.create(...)` | Environment or `Credentials.Of(...)` |
| `clientSecret` | Yes      | `Credentials.of(...)` | Environment or `Credentials.create(...)` | Environment or `Credentials.Of(...)` |
| `timeout`      | No       | Seconds; default `60` | Seconds; default `60`                    | Seconds; default `60`                |

## Token Management

The client requests a token on the first SDK operation, keeps it in memory and renews it before expiration. Token renewal uses a 60-second safety margin. Application code does not need a token-refresh task.

Create one client per test run. Creating a client for every method call discards the cached token.

## Next Step

[List the devices available to your account](docId\:T2lFRSsG2mhohPOA4K26-).
