Crear y refrescar token - OAuth - Mercado Pago Developers
¿Qué estás buscando?

¿No sabes cómo empezar la integración? 

Accede a los primeros pasos
Crear y refrescar token

POST

https://api.mercadopago.com/oauth/token
Para crear o actualizar el token necesario para operar su aplicación en nombre de un vendedor.
Parámetros para la solicitud
BODY
client_id
string

REQUERIDO

ID único que identifica tu aplicación/integración. Una de las claves del par que componen las credenciales que identifican una aplicación/integración en tu cuenta.
client_secret
string

REQUERIDO

Clave privada para ser utilizada en algunos complementos para generar pagos. Una de las claves del par que componen las credenciales que identifican una aplicación/integración en tu cuenta.
code
string
Código otorgado por el servidor de autenticación para que la aplicación pueda obtener un access token y un refresh token asociado. Tiene una validez de 10 minutos contados desde su generación. Obligatorio cuando grant_ty...Ver más
grant_type
string

REQUERIDO

Especifica el tipo de operación a realizar para obtener tus credenciales.
authorization_code: used to get the access token for the first time.
refresh_token: it is used to refresh an existing token.
Parámetros de respuesta
access_token
string
Código de seguridad que identifica al usuario, sus privilegios y una aplicación utilizada en diferentes solicitudes de origen público para acceder a los recursos protegidos. Su validez está determinada por el parámetro expires_in y es similar a APP_USR-1585551492-030918-25######3458-2880736 estando compuesto por
Access token type: APP_USR (application on behalf of a user), TEST (test, only valid in sandbox)
Client ID: 1585551492
Creation date (MMddHH): 030918
Ver más
token_type
string
información necesaria para que el token se utilice correctamente para acceder a los recursos protegidos. El token de tipo "bearer" es el único admitido por el servidor de autorización y se utiliza cuando el access token ...Ver más
expires_in
number
Tiempo de caducidad de access_token fijo expresado en segundos. De forma predeterminada, el tiempo de caducidad es de 180 días (15552000 segundos).
scope
string
Los scopes se utilizan en el proceso de autorización y consentimiento de la API y permiten determinar qué acceso solicita la aplicación y qué acceso otorga el usuario. De forma predeterminada, los ámbitos asociados con e...Ver más
Errores

400Error

invalid_client

The provided client_id and/or client_secret of your app is invalid.

invalid_grant

There are several reasons for this error, it could be because the authorization_code or refresh_token is invalid, expired or revoked, was sent in an incorrect flow, belongs to another client, or the redirect_uri used in the authorization flow does not match what your application has configured.

invalid_scope

The requested scope is invalid, unknown, or wrongly formed. The allowed values for the scope parameter are “offline_access”, ”write”, ”read”.

invalid_request

The request does not include a required parameter, includes an unsupported parameter or parameter value, has a duplicated value, or is otherwise malformed.

unsupported_grant_type

Allowed values for grant_type are “authorization_code” or “refresh_token”.

forbidden

The call does not authorize access, possibly another user's token is being used.

unauthorized_client

The application does not have a grant with the user or the permissions (scopes) that the application has with this user do not allow creating a token.

Solicitud
curl -X POST \
      'https://api.mercadopago.com/oauth/token'\
       -H 'Content-Type: application/json' \
       -d '{
  "client_id": "client_id",
  "client_secret": "client_secret",
  "code": "TG-XXXXXXXX-241983636",
  "grant_type": "authorization_code"
}'
Respuesta de ejemplo
{
  "access_token": "APP_USR-4934588586838432-XXXXXXXX-241983636",
  "token_type": "bearer",
  "expires_in": 15552000,
  "scope": "offline_access read write",
  "user_id": 241983636,
  "refresh_token": "TG-XXXXXXXX-241983636",
  "public_key": "APP_USR-d0a26210-XXXXXXXX-479f0400869e",
  "live_mode": true
}