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'
integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
string ls_StrResponseBody
integer li_RespStatusCode
oleobject loo_JsonResponse
string ls_Access_token
string ls_Token_type
integer li_Expires_in
string ls_Refresh_token
string ls_Client_id
string ls_UserName
string ls_Issued
string ls_Expires
loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
destroy loo_Rest
MessageBox("Error","Connecting to COM object failed")
return
end if
// URL: https://auth.fatturazioneelettronica.aruba.it/auth/signin
li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("auth.fatturazioneelettronica.aruba.it",li_Port,li_BTls,li_BAutoReconnect)
if li_Success <> 1 then
Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
end if
loo_Rest.AddQueryParam("grant_type","refresh_token")
loo_Rest.AddQueryParam("refresh_token","262ac1f88ad1e9e5")
ls_StrResponseBody = loo_Rest.FullRequestFormUrlEncoded("POST","/auth/signin")
if loo_Rest.LastMethodSuccess <> 1 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
end if
li_RespStatusCode = loo_Rest.ResponseStatusCode
if li_RespStatusCode >= 400 then
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
Write-Debug "Response Header:"
Write-Debug loo_Rest.ResponseHeader
Write-Debug "Response Body:"
Write-Debug ls_StrResponseBody
destroy loo_Rest
return
end if
loo_JsonResponse = create oleobject
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat_9_5_0.JsonObject")
loo_JsonResponse.Load(ls_StrResponseBody)
// See the Online Tool for Generating JSON Parse Code
ls_Access_token = loo_JsonResponse.StringOf("access_token")
ls_Token_type = loo_JsonResponse.StringOf("token_type")
li_Expires_in = loo_JsonResponse.IntOf("expires_in")
ls_Refresh_token = loo_JsonResponse.StringOf("refresh_token")
ls_Client_id = loo_JsonResponse.StringOf("client_id")
ls_UserName = loo_JsonResponse.StringOf("userName")
ls_Issued = loo_JsonResponse.StringOf("\".issued\"")
ls_Expires = loo_JsonResponse.StringOf("\".expires\"")
destroy loo_Rest
destroy loo_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"
}