Il token può essere rinnovato attraverso una richiesta di refresh che richiede i seguenti parametri in formato application/x-www-form-urlencoded con encoding UTF-8.
curl -X POST https://auth.fatturazioneelettronica.aruba.it/auth/signin \
-H 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8' \
-d 'grant_type=refresh_token' \
-d 'refresh_token=262ac1f88ad1e9e5'
#include <C_CkRestW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
const wchar_t *strResponseBody;
int respStatusCode;
HCkJsonObjectW jsonResponse;
const wchar_t *access_token;
const wchar_t *token_type;
int expires_in;
const wchar_t *refresh_token;
const wchar_t *client_id;
const wchar_t *userName;
const wchar_t *Issued;
const wchar_t *Expires;
rest = CkRestW_Create();
// URL: https://auth.fatturazioneelettronica.aruba.it/auth/signin
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRestW_Connect(rest,L"auth.fatturazioneelettronica.aruba.it",port,bTls,bAutoReconnect);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
CkRestW_AddQueryParam(rest,L"grant_type",L"refresh_token");
CkRestW_AddQueryParam(rest,L"refresh_token",L"262ac1f88ad1e9e5");
strResponseBody = CkRestW_fullRequestFormUrlEncoded(rest,L"POST",L"/auth/signin");
if (CkRestW_getLastMethodSuccess(rest) != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",strResponseBody);
CkRestW_Dispose(rest);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_Load(jsonResponse,strResponseBody);
// See the Online Tool for Generating JSON Parse Code
access_token = CkJsonObjectW_stringOf(jsonResponse,L"access_token");
token_type = CkJsonObjectW_stringOf(jsonResponse,L"token_type");
expires_in = CkJsonObjectW_IntOf(jsonResponse,L"expires_in");
refresh_token = CkJsonObjectW_stringOf(jsonResponse,L"refresh_token");
client_id = CkJsonObjectW_stringOf(jsonResponse,L"client_id");
userName = CkJsonObjectW_stringOf(jsonResponse,L"userName");
Issued = CkJsonObjectW_stringOf(jsonResponse,L"\".issued\"");
Expires = CkJsonObjectW_stringOf(jsonResponse,L"\".expires\"");
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(jsonResponse);
}
{
"access_token": "571a08cd6275e81e",
"token_type": "bearer",
"expires_in": 1800,
"refresh_token": "111ac1f88ad1efff",
"client_id": "123456",
"userName": "Utente",
".issued": "Mon, 21 Jan 2019 16:36:17 GMT",
".expires": "Mon, 21 Jan 2019 17:06:17 GMT"
}