I am trying to generate new access token using app_key, app_secret and refresh_token obtained using the following url.
https://www.dropbox.com/oauth2/authorize?client_id=<APP_KEY>&token_access_type=offline&response_type=code
but the response returned is
data: {
error: 'invalid_grant',
error_description: 'refresh token is malformed'
}
My App Specifications -
Permission Type -Scoped App (App Folder)
Code -
const axios = require('axios');
const clientId = 'xx';
const clientSecret = 'xx';
const refreshToken = 'xx';
axios({
method: 'post',
url: 'https://api.dropbox.com/oauth2/token',
params: {
grant_type: 'refresh_token',
refresh_token: refreshToken,
client_id: clientId,
client_secret: clientSecret
}
})
.then(response => {
const accessToken = response.data.access_token;
console.log(`Access token: ${accessToken}`);
// Use the access token to make API requests
})
.catch(error => {
console.error(error);
});