Discuss Dropbox Developer & API
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));
I see you're getting a 200 status code which should indicate that the call completed, but I don't see the actual response body here. Can you print out the response body? I can't offer help with fetch itself so you may need to refer to the fetch documentation for information on using it.
I figured it out.. I used the wrong method to print out the response body. I printed out the Response, when I should've printed out Response.json().
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!