Saltar al contenido

Obtener token de acceso

Solicitud

Emite un token de acceso de corta duración mediante el flujo OAuth 2.1 Client Credentials.

Proporciona:

  • Authorization: Basic base64(AppKey:AppSecret)
  • Content-Type: application/x-www-form-urlencoded
Seguridad
basicAuth
Cuerpoapplication/x-www-form-urlencodedrequerido
grant_typestringrequerido

Debe ser client_credentials.

Value:"client_credentials"
scopestring

Scopes opcionales separados por espacios.

Ejemplo:"API"
POST
/oauth2/token
curl -i -X POST \
  -u '<username>:<password>' \
  https://x-api.shipsaving.com/oauth2/token \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d grant_type=client_credentials \
  -d scope=API

Respuestas

Token de acceso emitido

Cuerpoapplication/json
access_tokenstring

Token de acceso JWT.

token_typestring
Ejemplo:"Bearer"
expires_ininteger, (int32)

Tiempo de expiración en segundos (1800 por defecto).

scopestring

Scopes otorgados (si se devuelven).

Response
{ "access_token": "eyJraWQiOiIxIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJTU19MSVZFX3RoNXE5S0pUZTBrdllsM3pRSFFmU0Q3NW5ETGlZQ2s4dlowSSIsImF1ZCI6IlNTX0xJVkVfdGg1cTlLSlRlMGt2WWwzelFIUWZTRDc1bkRMaVlDazh2WjBJIiwibmJmIjoxNzU0MzU1MzM0LCJjb21wYW55X2lkIjoiMTgyMyIsInVzZXJfaWQiOiIyNDA3Iiwic2NvcGUiOlsiQVBJIl0sImlzX3ZhbGlkIjp0cnVlLCJpc3MiOiJodHRwczovL3gtYXBpLnNoaXBzYXZpbmcudXMiLCJleHAiOjE3NTQzNTcxMzQsImlhdCI6MTc1NDM1NTMzNCwidGVzdF9tb2RlbCI6ZmFsc2V9.CsOfJozZUmd5cFrSodxGuDH0xxRQjau_qKwyOuJBPWigJeZXeoB_FgOl7r2kDfVndrru7IkXw5XCEmePkTJ25nyTD7RiysInBOuU0a89mfj4czedC8qHIHU-EI1CfRopHan2dCHfSog5skNT6edAmQfSNndj6mV18Pr0AclnhEgIG-CsfYkxZXRITXeqFKqiLfbUt8A4YsqT9zhXHqqttk42rBNzSddgBcBkHNGdys-qltEPc7xB_NpV02tZbsfl-hcHbHZYt_ufT4u4BLy5g7p6bd4Tt2vgUbRrVx-umCWuT3dad5di2Loj9vs2boywSCQshM1Aj4Fxzg8Sk-GsBw", "scope": "API", "token_type": "Bearer", "expires_in": 1799 }