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

# Authentication

> Authenticate with the OpenGame API using a creator token from the CLI, CI or your own scripts, or the session token a running game receives.

The creator API and the game API use different credentials. A creator token deploys. A session token is what a hosted game receives from the page around it.

## Creator tokens

Send the token on every creator request:

```bash theme={"system"}
curl --request GET \
  --url "https://opengame.io/api/v1/auth/me" \
  --header "Authorization: Bearer $OPENGAME_TOKEN"
```

Creator tokens start with `ogt_`.

`opengame login` opens a browser approval and creates a token with `read`, `deploy` and `submit`. A token made in settings can have fewer scopes, and can be limited to one game. Give a job only the scopes it needs: a preview job needs `deploy`, and only a job that submits a release needs `submit`.

A ready deploy goes to review by itself. With `submit` on the token that deployed it, the release can go live after review with no further step, but only when its description and genre are written, the jam is not offered to it, and the jam is not the only place it can go live. An update of a game that is already live also goes live by itself once review passes it, with the live version's details and jam entry. In every other case, and always when the token that deployed it lacks `submit`, the release waits for you to confirm its details: signed in on the deploy page, or with `POST /api/v1/submissions/{id}/publish` and a token holding `submit`, which is what `opengame publish` sends.

A token from `opengame login` lapses after 90 days without a request. Run `opengame login` again. A token made in settings does not lapse. Revoke either kind in settings. A token can revoke itself with `POST /api/v1/auth/logout`.

Store a CI token in the runner's secret store as `OPENGAME_TOKEN`. The CLI also accepts `--token-stdin`. Keep the value out of build output, source control, logs and command arguments.

Creating, listing or revoking other tokens needs a signed-in browser. [Sign-in](https://docs.opengame.io/api-reference/auth.md) has the device-login requests.

## Game sessions

A hosted game does not send a creator token. The OpenGame page injects a session token, and the SDK attaches it. Call `og.init()` before tracking events and `og.ready()` when the game is playable.

The game API is `https://api.opengame.gg/v1`. Scores, events and achievements use that session. Country lookup needs no session, though a browser can read it only from a live game or a live private preview. [Scores](https://docs.opengame.io/api-reference/scores.md), [events](https://docs.opengame.io/api-reference/events.md), [achievements](https://docs.opengame.io/api-reference/achievements.md) and [country](https://docs.opengame.io/api-reference/geo.md) are those routes.

## Browser session

A few creator routes, such as issuing a preview grant, need the signed-in browser session rather than a creator token. Those operations say so. A token can deploy and read status. It cannot open the preview page's grant by itself.


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