> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gamavas.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# Your server

> Know which player is talking to your server, check ownership, and unlock achievements only your server may grant.

Many games have a server: for saves, matchmaking, leaderboards or rewards. Gamavas Pass lets that server trust who's playing, without any login of its own.

## The rule: verify, don't trust

Never trust a player ID your game sends: anyone can send any ID. Have your game send the player's **access token** instead, and let your server ask Gamavas who it belongs to. Gamavas only accepts live tokens that were issued to **your** game, so a token from another game, or one that's expired or revoked, is refused.

```mermaid theme={"theme":{"light":"github-light","dark":"github-dark"}}
sequenceDiagram
  participant G as Your game
  participant S as Your server
  participant X as Gamavas
  G->>S: Request + access token
  S->>X: POST /server/players/verify (secret key)
  X-->>S: { playerId, handle, … }
  S-->>G: Response for that player
```

## 1. Create a secret key

On your app's **Keys** page in the [developer portal](https://developer.gamavas.fun), create a key. Copy it once; Gamavas only stores a hash.

* `gmv_sk_live_…` for production, `gmv_sk_test_…` for [test purchases](https://docs.gamavas.fun/pass/test-mode.md).
* Keep it on your server, in an environment variable. Gamavas refuses secret keys from browsers.
* If one leaks, revoke it on the same page and create a new one.

## 2. Send the token from your game

| SDK | Get the token |
| - | - |
| Web | `await pass.getAccessToken()` |
| Unity | `await GamavasPass.GetAccessTokenAsync()` |
| Godot | `(await GamavasPass.access_token()).value` |
| Construct 3 | **Get access token**, then `GamavasPass.AccessToken` |
| GameMaker | `gamavas_access_token(callback)` |
| Defold | `gamavas.access_token(callback)` |

Send it however your game talks to your server, for example in an `Authorization` header.

## 3. Verify it on your server

```ts Node, Bun, Deno, Workers theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { GamavasPass } from "@gamavas/pass-server";

const gamavas = new GamavasPass({ secretKey: process.env.GAMAVAS_SECRET_KEY });

const player = await gamavas.verifyPlayer(accessToken);
// { id, handle, displayName, avatarUrl, email, scopes }
```

```bash HTTP theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST https://gamavas.fun/api/pass/v1/server/players/verify \
  -H "Authorization: Bearer $GAMAVAS_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "accessToken": "…" }'
```

Use `player.id` as the key in your database. Profile fields and email follow what the player agreed to share.

## What else your server can do

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
await gamavas.owns(player.id);                    // bought it, or it's free
await gamavas.entitlement(player.id);             // { owned, free, priceCents, livemode }
await gamavas.unlock(player.id, "beat-the-boss"); // any achievement, including server-only ones
```

These work for players who have connected your game; others give `not_found`. Unlocking needs the player to have allowed progress, which the SDKs always ask for.

The [server SDK](https://docs.gamavas.fun/sdks/server.md) covers errors and options, and the [API reference](https://docs.gamavas.fun/api-reference/introduction.md) has every endpoint for other languages.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.