# 2. Credentials setup

{% hint style="warning" %}

#### Initialize After Media Source or MMP Initialization

Please initialize our SDK only after the media source or MMP data is initialized. This ensures that the media source data is sent correctly and prevents passing empty values.
{% endhint %}

To initializes the **TyrAds Unity SDK** you must provide the necessary credentials obtained from the TyrAds platform. These credentials allow your application to establish secure communication with the TyrAds' backend services. There are two supported approaches for setting up credentials: a Unity Editor–based approach and a code-based approach.

#### a. Unity Editor–based approach&#x20;

Once **TyrSDK** is imported, follow these steps to configure it in your project:

* **Open the Configuration Window**
  * Navigate to **TyrSDK > TyrSDK Settings** to access the **TyrSDK Settings** panel.
* **Enter Your Credentials**
  * **API Key:** A **32-character** hexadecimal string (Mandatory. Grabbed from TyrAds Dashboard).
  * **API Secret:** A **92-character** hexadecimal string(Mandatory. Grabbed from TyrAds Dashboard).
  * **Encryption Key:** A **32**-**character** hexadecimal string (Optional. Grabbed from TyrAds Dashboard).

<figure><img src="/files/QcnMZbcJWtqNrbchajqI" alt=""><figcaption></figcaption></figure>

#### b.  Code-based approach

You can initialize credentials programmatically. Credentials could be initialized by a call:

```csharp
SessionConfig sessionConfig = new(
                    apiKey: "TestApiKey",
                    apiSecret: "TestApiSecret",
                    encryptionKey: "testEncryptionKey");
InitConfig initConfig = new (sessionConfig);
TyrSDKPlugin.Instance.Init(initConfig);
```

`Init` method had to be called before calling `LoginUserAsunc` to ensure that your credentials are properly set before the login process begins.

**Notes**

If credentials are configured both in the Editor and via code, the programmatic initialization will override the Editor settings at runtime.

#### Using Different Credentials for Android and iOS&#x20;

In some projects, you may need to initialize the SDK with different credentials per platform (e.g., separate API keys for iOS and Android).

Editor-based configuration does not support platform-specific credentials, this type of configuration cannot be handled through the Settings Editor window.

To support platform-specific credentials, you must use the code-based initialization approach.

On the developer side, the application should detect the active platform at runtime and provide the correct credentials accordingly.

Below is a simple example demonstrating how to configure this:

```csharp
string apiKey = "DEFAULT_API_KEY";
string apiSecretv = "DEFAULT_API_SECRET";
string encryptionKey = "DEFAULT_ENCRYPTION_KEY";

#if UNITY_ANDROID
  apiKey = "ANDROID_API_KEY";
  apiSecretv = "ANDROID_API_SECRET";
  encryptionKey = "ANDROID_ENCRYPTION_KEY";
#elif UNITY_IOS
  apiKey = "IOS_API_KEY";
  apiSecretv = "IOS_API_SECRET";
  encryptionKey = "IOS_ENCRYPTION_KEY";
#endif

SessionConfig sessionConfig = new(
                    apiKey: "TestApiKey",
                    apiSecret: "TestApiSecret",
                    encryptionKey: "testEncryptionKey");
InitConfig initConfig = new (sessionConfig);
TyrSDKPlugin.Instance.Init(initConfig);
```


---

# Agent Instructions: 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:

```
GET https://sdk-doc.tyrads.com/unity/sdk-integration/2.-credentials-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
