const payloadBase64 = token.split('.')[1];
const decodedJson = Buffer.from(payloadBase64, 'base64').toString();
const decoded = JSON.parse(decodedJson);
const exp = decoded.exp;
const expired = Date.now() >= exp * 1000;
const axios = require('axios');
const API_URL = 'https://api.furo.one';
const refreshToken = 'YOUR_REFRESH_TOKEN';
const oldAccessToken = 'YOUR_OLD_ACCESS_TOKEN';
async function refreshAccessToken() {
try {
const response = await axios.post(
`${API_URL}/sessions/token/refresh`,
{
accessToken: oldAccessToken,
},
{
headers: {
Authorization: `Bearer ${refreshToken}`,
},
}
);
console.log('Response:', response.data);
} catch (error) {
console.error('Error:', error.message);
}
}
refreshAccessToken();