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

# Exchange a code, or refresh

> Exchange the sign-in code (with the PKCE verifier) for tokens, or a refresh token for new ones. Refresh tokens rotate: keep the new one.



## OpenAPI

````yaml /api-reference/openapi.json post /auth/oauth2/token
openapi: 3.1.0
info:
  title: Gamavas Pass API
  version: 1.0.0
  summary: Sign in with Gamavas, achievements and XP, selling games, and webhooks.
  description: >-
    Games sign players in with OAuth 2.1 and PKCE (the SDKs do this for you),
    then call the game API with the player's access token. A game's server uses
    a secret key (`gmv_sk_live_…`, or `gmv_sk_test_…` for test purchases) and
    never sends it from a browser. Errors are JSON: `{ "error": "what happened"
    }`.
  contact:
    name: Gamavas developers
    url: https://docs.gamavas.fun
servers:
  - url: https://gamavas.fun/api
    description: Gamavas
security: []
tags:
  - name: Sign-in
    description: OAuth 2.1 and OpenID Connect. The SDKs do this for you.
  - name: Game
    description: Called by your game with the player's access token.
  - name: Server
    description: Called by your server with a secret key.
  - name: Webhooks
    description: Sent by Gamavas to your server.
paths:
  /auth/oauth2/token:
    post:
      tags:
        - Sign-in
      summary: Exchange a code, or refresh
      description: >-
        Exchange the sign-in code (with the PKCE verifier) for tokens, or a
        refresh token for new ones. Refresh tokens rotate: keep the new one.
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - grant_type
                - client_id
              properties:
                grant_type:
                  type: string
                  enum:
                    - authorization_code
                    - refresh_token
                client_id:
                  type: string
                code:
                  type: string
                code_verifier:
                  type: string
                redirect_uri:
                  type: string
                refresh_token:
                  type: string
      responses:
        '200':
          description: Tokens.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tokens'
        '400':
          description: '`{ error, error_description }`, e.g. `invalid_grant`.'
          content:
            application/json:
              schema:
                type: object
      security: []
components:
  schemas:
    Tokens:
      type: object
      required:
        - access_token
        - token_type
        - expires_in
      properties:
        access_token:
          type: string
        token_type:
          type: string
          description: '`Bearer`.'
        expires_in:
          type: integer
          description: Seconds.
        refresh_token:
          type: string
          description: With `offline_access`. Rotates on use.
        id_token:
          type: string
          description: A signed JWT; check `aud` and `nonce`.
        scope:
          type: string

````

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