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

# How sign-in works

> What happens when a player presses “Sign in with Gamavas”: the popup, the addresses sign-in returns to, scopes, and staying signed in.

Gamavas Pass is OAuth 2.1 with PKCE and OpenID Connect, wrapped so you never handle the protocol yourself. Each SDK does the steps below for its platform.

```mermaid theme={"theme":{"light":"github-light","dark":"github-dark"}}
sequenceDiagram
  participant P as Player
  participant G as Your game
  participant X as Gamavas
  P->>G: Presses "Sign in with Gamavas"
  G->>X: Opens /authorize (client ID, return address, PKCE challenge)
  X->>P: Sign in or create an account, approve your game once
  X-->>G: Back to your return address with a one-time code
  G->>X: Exchanges the code + PKCE verifier for tokens
  X-->>G: Access token, refresh token, ID token
```

## Where sign-in returns

Gamavas only sends players back to addresses you register for your app, under **Where sign-in returns** in the [developer portal](https://developer.gamavas.fun). They must match exactly.

| Your game runs… | Register | Example |
| - | - | - |
| On a web page | The page's address, without anything after `?` or `#` | `https://your-game.example/` |
| As a desktop app | The loopback address. Any port works, as the standard for native apps allows | `http://127.0.0.1/` |
| As a mobile app | Your reverse-domain app link, with one slash | `com.studio.game:/pass` |

Add your local test address too, for example `http://localhost:5173/`. Only `localhost` and `127.0.0.1` may use `http`.

## The popup, and when it's blocked

On the web, sign-in opens in a small popup, so your game keeps running underneath. The popup comes back to your registered page, the Gamavas script on that page hands the result to your game's window, and the popup closes.

Browsers only allow popups straight after a click or a tap. That's why every SDK starts sign-in **on press**, and why you should call it from an input handler. If a browser blocks the popup anyway, the whole page goes to Gamavas and comes back signed in. The SDK finishes that sign-in when your game loads again (`pass.ready` on the web).

> [!TIP]
>
> Load the Gamavas script in your page's `<head>`. Then the popup can close before your game starts loading inside it.

On desktop and mobile, sign-in uses the player's own browser, never a web view inside your game. Players can see the real Gamavas address, and they can use their saved passwords.

## Scopes

The SDKs ask for what most games need:

| Scope | What it gives | Asked for |
| - | - | - |
| `openid` | The player's Gamavas ID | Always |
| `profile` | Handle, display name and avatar | Always |
| `offline_access` | A refresh token, so players stay signed in | Always |
| `progress` | Their level, your achievements and unlocking them | Always |
| `email` | Their email address | Only if you ask, and they can decline |

The consent screen tells players exactly what your game will get. They approve once; after that, signing in is one click.

## Staying signed in

Players stay signed in between visits. The SDKs keep the refresh token (in local storage, `PlayerPrefs` or your engine's equivalent) and refresh the short-lived access token when it's needed. Refresh tokens rotate on every use.

A player can disconnect your game at any time in their Gamavas settings. After that, the next refresh fails, the SDK signs them out, and your player-changed callback fires.

**Signing out** of your game revokes its refresh token. It doesn't sign the player out of Gamavas itself.

## Before your listing is live

Until your game's listing is published, only you can sign in to it. You can build and test while it's in review, and nobody else can connect it yet.

## Under the hood

* Nothing secret lives in your game: PKCE replaces the client secret. Your client ID is public.
* The ID token is a signed JWT. The SDKs check its issuer, audience and nonce.
* OpenID Connect discovery is at `https://gamavas.fun/api/auth/.well-known/openid-configuration`.
* The raw endpoints are in the [API reference](https://docs.gamavas.fun/api-reference/introduction.md).


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