> ## 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.

# Godot

> Gamavas Pass for Godot 4: an autoload for sign-in, achievements and selling, on web exports and desktop.

| Export | How players sign in |
| - | - |
| **Web** | The Gamavas popup, through the Gamavas script in your page |
| **Windows, macOS, Linux** (and the editor) | The system browser, then back to the game |

Godot 4.2 or later. Pure GDScript, with no native libraries. Android and iOS aren't supported yet.

## Install

**1. Add the addon**

Download `gamavas_pass-godot-<version>.zip` from [github.com/Gamavas/pass-godot/releases](https://github.com/Gamavas/pass-godot/releases) and copy `addons/gamavas_pass` into your project's `addons/` folder.

**2. Enable it**

In **Project → Project Settings → Plugins**, turn on **Gamavas Pass**. That adds the `GamavasPass` autoload.

**3. Connect your game**

At [developer.gamavas.fun](https://developer.gamavas.fun), connect your listing to get a client ID. Under **Where sign-in returns**, add your game's page for web exports and `http://127.0.0.1/` for desktop.

## Sign players in

```gdscript theme={"theme":{"light":"github-light","dark":"github-dark"}}
extends Node

func _ready() -> void:
    GamavasPass.init("YOUR_CLIENT_ID")
    GamavasPass.player_changed.connect(func(player):
        print("Signed out" if player == null else "Hi @" + player.handle))

func _on_sign_in_pressed() -> void:
    var r = await GamavasPass.sign_in()
    if not r.ok:
        print(r.error, ": ", r.message)   # "cancelled", "timeout", "access_denied"…
```

Or add a **GamavasSignInButton** node (Add Child Node → GamavasSignInButton). It starts on press, so on the web the popup opens inside the click. When the player is signed in, it shows their handle and signs them out on press.

Every call returns a Dictionary instead of raising an error:

```gdscript theme={"theme":{"light":"github-light","dark":"github-dark"}}
{ ok = true,  value = <the answer>, error = "",     message = "" }
{ ok = false, value = null,         error = "code", message = "what happened" }
```

`GamavasPass.player` is the signed-in player, remembered between sessions, or `null`: `{ id, handle, displayName, avatarUrl, email }`.

## Achievements, progress and selling

```gdscript theme={"theme":{"light":"github-light","dark":"github-dark"}}
var r = await GamavasPass.unlock("first-win")   # web: shows "Achievement unlocked"
if r.ok and r.value.newlyUnlocked:
    print("+", r.value.xpAwarded, " XP")

var list = await GamavasPass.achievements()     # [{ key, name, description, iconUrl, xp, unlocked, unlockedAt }]
var me = await GamavasPass.progress()           # { xp, level, title, toNextLevel }

var owned = await GamavasPass.owns()
if owned.ok and not owned.value:
    var bought = await GamavasPass.purchase()   # web: popup (from a click). Desktop: browser.
```

On desktop, `purchase()` checks every few seconds until the game is owned, for up to 15 minutes. Call `GamavasPass.cancel_purchase()` if the player goes back, and `GamavasPass.cancel_sign_in()` to stop waiting for a browser sign-in.

## Web export

In your Web export preset, add this to **HTML → Head Include**:

```html theme={"theme":{"light":"github-light","dark":"github-dark"}}
<script src="https://gamavas.fun/sdk/pass.js"></script>
```

## Your server

```gdscript theme={"theme":{"light":"github-light","dark":"github-dark"}}
var r = await GamavasPass.access_token()   # r.value: the token; "signed_out" if no one is
```

Send it to your server and verify it there with [`@gamavas/pass-server`](https://docs.gamavas.fun/sdks/server).

## Options

```gdscript theme={"theme":{"light":"github-light","dark":"github-dark"}}
GamavasPass.init("YOUR_CLIENT_ID", {
    "analytics": true,       # play time for your Analytics page; never earns XP
    "test": false,           # test purchases for you and your testers; off before you ship
    "loopback_path": "/",    # desktop: the path on http://127.0.0.1/ that sign-in returns to
    "issuer": "https://staging.gamavas.fun/api/auth",  # only for testing against staging
})
```

On desktop, the player is remembered in `user://gamavas_pass.cfg`.


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