Refreshing Tokens


Ecco tutti i passaggi per ottenere un nuovo token di accesso e aggiornare il token.

Endpoint

Method URI
POST https://fatture.keliweb.it/oauth/token

Request Parameters

Parameter Type Description Required
grant_type string default value: refresh_token Yes
client_id string The client ID provided to access APIs Yes
client_secret string The client secret key provided to access APIs Yes
refresh_token string The refresh token Yes

Response Parameters

Parameter Type Description
token_type string default value: Bearer
expires_in integer The token lifetime (in seconds)
access_token string The access token
refresh_token string The refresh token

Example Request (BASH Curl)

curl --location --request POST 'https://fatture.keliweb.it/oauth/token' \
--form 'grant_type="refresh_token"' \
--form 'client_id="4a6af340-2672-11ec-8114-3ba47a898cf0"' \
--form 'client_secret="UhoPgAS8rnAm57J8dLXWqKDTFnwjzS30pLzE572Z"'
--form 'refresh_token="def50200cb918cb70defe79d45f1f2193c4c0a959fd78a5c3123e5d3f33"' \

Example Request (PHP Curl)

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://fatture.keliweb.it/oauth/token",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => false,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>
    http_build_query(
            array(
                'grant_type'    => 'refresh_token',
                'client_id'     => 'ea9ea94e-a0c2-4b87-9834-26b218ed26a0',
                'client_secret' => 'MoQSElJG5MoLkVhRJCJ7jdQZVwfbrtwKKepwOsXO',
                'refresh_token' => 'def50200cb918cb70defe79d45f1f2193c4c0a959fd78a5c3123e5d3f33f',
            )
        ),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/x-www-form-urlencoded",
    "X-Requested-With: XMLHttpRequest"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Example Request (jQuery AJAX)

var form = new FormData();

form.append("grant_type", "refresh_token");
form.append("client_id", "ea9ea94e-a0c2-4b87-9834-26b218ed26a0");
form.append("client_secret", "MoQSElJG5MoLkVhRJCJ7jdQZVwfbrtwKKepwOsXO");
form.append(
    "refresh_token",
    "def50200cb918cb70defe79d45f1f2193c4c0a959fd78a5c3123e5d3f33f3b8af6b1080f6c74"
);

var settings = {
    async: true,
    crossDomain: true,
    url: "https://fatture.keliweb.it/oauth/token",
    method: "POST",
    headers: {
        "cache-control": "no-cache"
    },
    processData: false,
    contentType: false,
    mimeType: "multipart/form-data",
    data: form
};

$.ajax(settings).done(function(response) {
    console.log(response);
});

Example Request (Python - Requests)

import requests

url = "https://fatture.keliweb.it/oauth/token"

payload={'grant_type': 'refresh_token',
'refresh_token': 'def50200cb918cb70defe79d45f1f2193c4c0a959fd78a5c3123e5d3f33f3b8af6b1080f6c74',
'client_id': '4a6af340-2672-11ec-8114-3ba47a898cf0',
'client_secret': 'UhoPgAS8rnAm57J8dLXWqKDTFnwjzS30pLzE572Z'}
files=[

]
headers = {}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

Example Response (JSON payload)

{
    "token_type": "Bearer",
    "expires_in": 3600,
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImYyYjBjOWNkODFiYzRmODMwOGZlNjZkZ",
    "refresh_token": "def50200cb918cb70defe79d45f1f2193c4c0a959fd78a5c3123e5d3f33f3b8af6b1080f6c745"
}