Canjear el code de Meta
POST /api/marketing/oauth/exchangeValida el state, canjea el code por un token long-lived y da de alta una cuenta por cada cuenta publicitaria a la que el usuario dio acceso, en estado available. El cliente después elige cuáles activar. Requiere scope marketing:manage.
Request body
Section titled “Request body”| Field | Type | Description | |
|---|---|---|---|
code | string | required | code que Meta devolvió en el redirect. |
redirect_uri | string | required | El MISMO redirect_uri con el que se pidió la URL. Meta lo compara y rechaza el canje si no coincide exactamente. |
state | string | required | El state firmado que emitió GET /oauth/url. |
Responses
Section titled “Responses”| Status | Description | Schema |
|---|---|---|
200 | — | — |
400 | El usuario no otorgó ads_management (o el state no es válido). | MissingPermissionResponseDto |
Example
Section titled “Example”curl -X POST https://api.neike.dev/api/marketing/oauth/exchange \ -H "x-neike-api-key: whk_live_…" \ -H "Content-Type: application/json" \ -d '{ "code": "string", "redirect_uri": "string", "state": "string" }'MissingPermissionResponseDto
Section titled “MissingPermissionResponseDto”| Field | Type | Description | |
|---|---|---|---|
error | missing_permission | required | — |
message | string | required | — |
missing | string[] | optional | Permisos que el usuario no otorgó en el diálogo de Meta. Example: ["ads_management"]. |