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'
#import <CkoRest.h>
#import <NSString.h>
#import <CkoJsonObject.h>
CkoRest *rest = [[CkoRest alloc] init];
BOOL success;
// URL: https://auth.fatturazioneelettronica.aruba.it/auth/signin
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"auth.fatturazioneelettronica.aruba.it" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
NSLog(@"%@",rest.LastErrorText);
return;
}
[rest AddQueryParam: @"grant_type" value: @"refresh_token"];
[rest AddQueryParam: @"refresh_token" value: @"262ac1f88ad1e9e5"];
NSString *strResponseBody = [rest FullRequestFormUrlEncoded: @"POST" uriPath: @"/auth/signin"];
if (rest.LastMethodSuccess != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
int respStatusCode = [rest.ResponseStatusCode intValue];
if (respStatusCode >= 400) {
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",rest.ResponseHeader);
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",strResponseBody);
return;
}
CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse Load: strResponseBody];
// See the Online Tool for Generating JSON Parse Code
NSString *access_token = 0;
NSString *token_type = 0;
int expires_in;
NSString *refresh_token = 0;
NSString *client_id = 0;
NSString *userName = 0;
NSString *Issued = 0;
NSString *Expires = 0;
access_token = [jsonResponse StringOf: @"access_token"];
token_type = [jsonResponse StringOf: @"token_type"];
expires_in = [[jsonResponse IntOf: @"expires_in"] intValue];
refresh_token = [jsonResponse StringOf: @"refresh_token"];
client_id = [jsonResponse StringOf: @"client_id"];
userName = [jsonResponse StringOf: @"userName"];
Issued = [jsonResponse StringOf: @"\".issued\""];
Expires = [jsonResponse StringOf: @"\".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"
}