I am new to using https in Node.js, and Dropbox API, and am not familiar with the syntax. I have had no success finding Javascript examples on how to get an access token from a refresh token, and am asking here.
below is my current syntax, and i get the error:
{"error": "unsupported_grant_type", "error_description": "missing required field \"grant_type\""}
import * as https from "https";
const req = https.request("https://api.dropbox.com/oauth2/token",{
method: "POST",
headers:{
"Authorization":`Basic ${Buffer.from(`${<APP_KEY>}:${<SECRET_KEY>}`).toString("base64")}`,
"Content-Type":"application/x-www-form-urlencoded"
}
}, (res) => {
res.on("data", function(rawdat){
console.log(rawdat.toString());
})
});
req.write(JSON.stringify({
grant_type:"refresh_token",
refresh_token: <REFRESH_TOKEN>
}));
req.end();
This was cobbled together using what I understood from downloading and uploading, which I have successfully done using short-lived access tokens generated from the dashboard. Now however, I require access to the by dropbox app folder with a regular supply of access tokens.