Refresh Access Token
Endpoint for refreshing access tokens when they expire.
Request Syntax
POST /auth/refresh HTTP/1.1
Host: api.excoinz.com
EXCOINZ_SECRET: ${SECRET_KEY}
Content-Type: application/json
Rather than running a schedule on a calendar cycle, the Check the exp value before the API request or have it run as a handling for error codes.
Request
Response
Sample
curl -X POST https://api.excoinz.com/auth/refresh \
-H "EXCOINZ_SECRET: ${SECRET_KEY}" \
-H "Content-Type: application/json" \
-d '{
"client_id": "YOUR_CLIENT_ID",
"access": "YOUR_ACCESS",
"refresh": "YOUR_REFRESH"
}'
const axios = require('axios');
const SECRET_KEY = 'YOUR_SECRET_KEY';
const requestData = {
client_id: 'YOUR_CLIENT_ID',
access: 'YOUR_ACCESS',
refresh: 'YOUR_REFRESH'
};
axios.post('https://api.excoinz.com/auth/refresh', requestData, {
headers: {
'EXCOINZ_SECRET': `Bearer ${SECRET_KEY}`,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Map;
@Service
public class ExcoinzService {
private static final String ENDPOINT_URL = "https://api.excoinz.com/auth/refresh";
private static final String SECRET_KEY = "YOUR_SECRET_KEY";
public ResponseEntity<String> refreshToken() {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("EXCOINZ_SECRET", "Bearer " + SECRET_KEY);
Map<String, Object> body = new HashMap<>();
body.put("client_id", "YOUR_CLIENT_ID");
body.put("access", "YOUR_ACCESS");
body.put("refresh", "YOUR_REFRESH");
HttpEntity<Map<String, Object>> entity = new HttpEntity<>(body, headers);
ResponseEntity<String> response = restTemplate.exchange(ENDPOINT_URL, HttpMethod.POST, entity, String.class);
return response;
}
}
<?php
$url = 'https://api.excoinz.com/auth/refresh';
$SECRET_KEY = 'YOUR_SECRET_KEY';
$client_id = 'YOUR_CLIENT_ID';
$access = 'YOUR_ACCESS';
$refresh = 'YOUR_REFRESH';
$headers = array(
"EXCOINZ_SECRET: Bearer $SECRET_KEY",
"Content-Type: application/json"
);
$data = array(
"client_id" => $client_id,
"access" => $access,
"refresh" => $refresh
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($error = curl_error($ch)) {
die('cURL error: ' . $error);
}
curl_close($ch);
echo $response;
?>
Last updated