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 <CkRestW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
CkRestW rest;
bool success;
// URL: https://auth.fatturazioneelettronica.aruba.it/auth/signin
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = rest.Connect(L"auth.fatturazioneelettronica.aruba.it",port,bTls,bAutoReconnect);
if (success != true) {
wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
wprintf(L"%s\n",rest.lastErrorText());
return;
}
rest.AddQueryParam(L"grant_type",L"refresh_token");
rest.AddQueryParam(L"refresh_token",L"262ac1f88ad1e9e5");
const wchar_t *strResponseBody = rest.fullRequestFormUrlEncoded(L"POST",L"/auth/signin");
if (rest.get_LastMethodSuccess() != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",rest.responseHeader());
wprintf(L"Response Body:\n");
wprintf(L"%s\n",strResponseBody);
return;
}
CkJsonObjectW jsonResponse;
jsonResponse.Load(strResponseBody);
// See the Online Tool for Generating JSON Parse Code
const wchar_t *access_token = 0;
const wchar_t *token_type = 0;
int expires_in;
const wchar_t *refresh_token = 0;
const wchar_t *client_id = 0;
const wchar_t *userName = 0;
const wchar_t *Issued = 0;
const wchar_t *Expires = 0;
access_token = jsonResponse.stringOf(L"access_token");
token_type = jsonResponse.stringOf(L"token_type");
expires_in = jsonResponse.IntOf(L"expires_in");
refresh_token = jsonResponse.stringOf(L"refresh_token");
client_id = jsonResponse.stringOf(L"client_id");
userName = jsonResponse.stringOf(L"userName");
Issued = jsonResponse.stringOf(L"\".issued\"");
Expires = jsonResponse.stringOf(L"\".expires\"");
}
{
"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"
}