When I try to get an access Token using Fetch in JavaScript via the in the title specified endpoint, it returns this:
{"webSocket":null,"url":"https://api.dropboxapi.com/oauth2/token","redirected":false,"ok":true,"headers":{},"statusText":"OK","status":200,"bodyUsed":false,"body":{"locked":false}}
My Code is this:
async function getInitial() {
let dropBoxConnection = await fetch(`https://api.dropboxapi.com/oauth2/token`, {
body: new URLSearchParams({
code: dropToken,
grant_type: 'authorization_code',
redirect_uri: DropBoxData.redirect,
client_id: DropBoxData.key,
client_secret: DropBoxData.secret
}),
method: "POST"
}).then((response) => {
return response;
}).catch((error) => {
return new Error(error);
});
return await dropBoxConnection;
}
if(dropToken) var DropboxReturn = await getInitial();
return new Response("Old Token: " + dropToken + ";" + " API-Response: " + JSON.stringify(DropboxReturn));