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

# Obter ou renovar tokens

> Troca `authorization_code` por tokens (com `code_verifier`) ou renova com `refresh_token`. Refresh tokens rotacionam a cada uso.



## OpenAPI

````yaml /es/oauth-api/api-reference/openapi-oauth.json post /oauth/token
openapi: 3.0.3
info:
  title: Notifique API. OAuth 2.1
  description: >-
    Authorization Server OAuth 2.1 con PKCE obligatorio. Registra clientes,
    autoriza usuarios y obtén access tokens para `/v1/*`. Issuer:
    `https://api.notifique.dev`.
  version: 1.0.0
servers:
  - url: https://api.notifique.dev
    description: Produção
security: []
tags:
  - name: Metadados
    description: Discovery RFC 8414, chaves públicas JWT e metadados do recurso MCP.
  - name: OAuth
    description: Registro de clientes, autorização, tokens e revogação.
  - name: OAuth Apps
    description: Apps OAuth do workspace (painel Developer → OAuth Apps).
paths:
  /oauth/token:
    post:
      tags:
        - OAuth
      summary: Obter ou renovar tokens
      description: >-
        Troca `authorization_code` por tokens (com `code_verifier`) ou renova
        com `refresh_token`. Refresh tokens rotacionam a cada uso.
      operationId: ntfOauth_token
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              oneOf:
                - $ref: '#/components/schemas/NtfOauth_AuthorizationCodeGrant'
                - $ref: '#/components/schemas/NtfOauth_RefreshTokenGrant'
            examples:
              authorization_code:
                summary: Trocar code por tokens
                value:
                  grant_type: authorization_code
                  code: auth_code_abc
                  redirect_uri: https://meuapp.com/oauth/callback
                  code_verifier: dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
              refresh_token:
                summary: Renovar access token
                value:
                  grant_type: refresh_token
                  refresh_token: rt_opaque_xyz
      responses:
        '200':
          description: Tokens emitidos.
          content:
            application/json:
              example:
                access_token: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...
                token_type: Bearer
                expires_in: 900
                refresh_token: rt_opaque_new
                scope: email:send
              schema:
                $ref: '#/components/schemas/ntfOauth_TokenResponse'
        '400':
          description: Grant inválido (`invalid_grant`, PKCE incorreto, code expirado).
        '401':
          description: Cliente não autenticado (confidencial sem secret válido).
components:
  schemas:
    NtfOauth_AuthorizationCodeGrant:
      type: object
      required:
        - grant_type
        - code
        - redirect_uri
        - code_verifier
      properties:
        grant_type:
          type: string
          enum:
            - authorization_code
        code:
          type: string
        redirect_uri:
          type: string
          format: uri
        code_verifier:
          type: string
      example:
        grant_type: authorization_code
        code: string
        redirect_uri: https://example.com/resource
        code_verifier: string
    NtfOauth_RefreshTokenGrant:
      type: object
      required:
        - grant_type
        - refresh_token
      properties:
        grant_type:
          type: string
          enum:
            - refresh_token
        refresh_token:
          type: string
      example:
        grant_type: refresh_token
        refresh_token: string
    ntfOauth_TokenResponse:
      type: object
      properties:
        access_token:
          type: string
        token_type:
          type: string
        expires_in:
          type: integer
        refresh_token:
          type: string
        scope:
          type: string
      example:
        access_token: string
        token_type: string
        expires_in: 1
        refresh_token: string
        scope: string

````