Hello!
I need help because I'm a little confused with the refresh token for integrations via API
I am using this guide: https://www.dropbox.com/developers/documentation/http/documentation#oauth2-token, and I follow these steps but I always get the malformed token response
1 - Get the code from https://www.dropbox.com/oauth2/authorize?client_id=<client_id>&response_type=code&token_access_type=offline
2- The result of the previous request, use it in https://api.dropbox.com/oauth2/token?grant_type=authorization_code&code=<code_1>&client_id=<client_id>&client_secret=<client_secret>
3 - Finally, the token from point 2 is used in https://api.dropbox.com/oauth2/token?grant_type=refresh_token&refresh_token=<refreshToken2>&client_id=<client_id>&client_secret=<client_secret>
Regarding point 3, I am structuring the request like this in NestJs. The rest I consult in Postman
try {
const response = await axios.post('https://api.dropbox.com/oauth2/token', null, {
params: {
grant_type: 'refresh_token',
refresh_token: "token",
client_id: "clientid",
client_secret: "clientsecret",
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
this.accessToken = response.data.access_token;
this.dbx = new Dropbox({ accessToken: this.accessToken }); // Actualiza el cliente de Dropbox con el nuevo token
} catch (error) {
console.log(error);
console.error('Error refreshing access token:', error.response?.data || error.message);
throw error;
}
Question, am I doing something wrong?.
I have read in older topics that the authorization code is taken from another endpoint, but I couldn't find it, or I didn't realize it.
I await comments. Thanks!