# Getting started, step by step

> What to ask the platform team for, where each value goes, and the whole integration as a short list of steps, each linking to its details.

## 1. Ask for your credentials

The Baziness platform team gives you these values, **one set per environment** (development and production):

| Value | Example | Used by | Secret? |
| --- | --- | --- | --- |
| **Client id** | `12` | your server, to get a client token | no, but keep it private |
| **Client secret** | `••••••••` | your server, to get a client token | **yes — server only** |
| **Platform package name** | `com.karizmastudio.example` | every Baziness page link (`packageName`) | no |
| **Game name** | `example` | the reward page and the game offer page (`game_name`) | no |
| **Pay package name** | `com.karizmastudio.example` | every Baziness Pay call (`pname`); may differ from the platform package | no |
| **SKUs** | `example_pack` | the products you sell with Baziness Pay | no |

> [!WARNING]
> The client secret must **never** reach a browser or an app build: not in client code, not in a `VITE_*` or `NEXT_PUBLIC_*` variable, not in git. Anyone holding it can create players and **give Gita coins** as your game.

## 2. Understand the two tokens

Everything on the platform uses one of two tokens. Keeping them apart is the key to the whole integration:

| Token | Who has it | How it is obtained | What it is for |
| --- | --- | --- | --- |
| **Client token** | **your server only** | client id + client secret → [`client/auth`](platform-api.md#step-1-get-a-client-token) | every server-to-server call: creating players, checking tokens, giving coins |
| **User token** | the player's client (from your server) | [`client/create-user`](platform-api.md#step-2-create-a-baziness-user-for-a-player) or [`client/get-user-token`](platform-api.md#step-3-get-a-fresh-user-token) | opening Baziness pages as this player (`linkedToken`), reading their coin balance |

## 3. Follow the steps

| # | Step | Where | Details |
| --- | --- | --- | --- |
| 1 | Your server gets a **client token** with the client id and secret | server | [Platform API → step 1](platform-api.md#step-1-get-a-client-token) |
| 2 | On a player's first visit, your server **creates their Baziness user** and saves its id. On later visits it **gets a fresh user token** | server | [steps 2–3](platform-api.md#step-2-create-a-baziness-user-for-a-player) |
| 3 | Your client **shows Baziness pages** (sign-in, profile, rewards) with the user token, and listens to their messages | client | [Baziness pages](pages.md) |
| 4 | When the player signs in on a page, your server **checks the token** and links the account (or switches to the player's other account) | server | [Login](login.md), [step 4](platform-api.md#step-4-verify-a-token-from-the-client) |
| 5 | Your client **shows the Gita coin balance**, and your server **gives Gita coins** for wins and rewards | both | [Gita coins](coins.md), [steps 5–6](platform-api.md#step-5-give-gita-coins) |
| 6 | The «انتخاب جایزه» button opens the **reward page**; the tutorial can open your **game offer page** | client | [Reward page](rewards.md), [Tutorial offer page](game-offer.md) |
| 7 | Sell items with **Baziness Pay** | both | [Baziness Pay](pay-api.md) |
| 8 | Tag the links that bring players in with **UTM parameters** | both | [Links & UTM](links.md) |

Ready-made code for every step is in [Server code](samples-server.md) and [Client code](samples-client.md). The [example game](example.md) puts it all together.

## 4. Configure your server

The example game and the code samples read these settings. Use the same names, so samples can be copied unchanged:

| Setting | Example | Meaning |
| --- | --- | --- |
| `BAZINESS_PLATFORM_ENABLED` | `true` | master switch. While `false`, the game shows no Baziness UI at all |
| `BAZINESS_PLATFORM_USE_PRODUCTION` | `false` | `false` = development URLs, `true` = production URLs |
| `BAZINESS_CLIENT_ID` | `12` | client id |
| `BAZINESS_CLIENT_SECRET` | `••••` | client secret (**secret**) |
| `BAZINESS_PLATFORM_PACKAGE_NAME` | `com.karizmastudio.example` | `packageName` on page links |
| `BAZINESS_GAME_NAME` | `example` | `game_name` on the reward and offer pages |
| `BAZINESS_PAY_ENABLED` | `true` | turns the buy buttons on |
| `BAZINESS_PAY_BASE_URL` | `https://pay-dev.karizmastudios.org` | the Pay server for this environment |
| `BAZINESS_PAY_PACKAGE_NAME` | `com.karizmastudio.example` | `pname` on every Pay call |
| `BAZINESS_SKU_PREFIX` | *(empty)* | optional: SKU = prefix + product id |

The platform counts as **on** only when `BAZINESS_PLATFORM_ENABLED=true` **and** both the client id and the secret are set. A half-configured server then behaves as if Baziness didn't exist.
