Our Community is in read-only mode until April 8th, learn more here. You can still search existing threads or get help via Dropbox Support, the Dropbox Help Center, or Learn.
Forum Discussion
Jenya Korolenko
5 years agoExplorer | Level 3
Can't get access token uses javascript fetch request
Hi everyone, l try to get access token uses javascript fetch in the next way:
fetch('https://api.dropboxapi.com/oauth2/token', {
method: 'POST',
code: AUTHORIZATION_CODE,
grant_type: 'a...
Greg-DB
Dropbox Community Moderator
5 years agocascadeCommons The /2/file_requests/create endpoint is an "RPC" style endpoint, so it does work a bit differently than the /oauth2/token endpoint.
Calling /2/file_requests/create with fetch, for instance, would look like this, again building on the original example here:
var headers = {
'Authorization': "Bearer ACCESS_TOKEN",
'Content-Type': "application/json"
};
var params = JSON.stringify({"title": "file request title", "destination": "/file request destination"});
fetch('https://api.dropboxapi.com/2/file_requests/create', {
method: 'POST',
body: params,
headers: headers,
})
.then(res => res.json())
.then(data => console.log('access data =>', data))
.catch(err => console.log('access err =>', err));
cascadeCommons
5 years agoExplorer | Level 4
Thank you so much Greg for your quick reply, I really appreciate it.
It seems that I had formatted my fetch request correctly, but the issue I was having was working with the response data. I checked my code using the .ok property and I can confirm that the request is successful. In the example you provided, there were 2 .then() statements. I was wondering if you could provide some guidance on how to access properties of the response, such as the file request URL. For refernce, this is what the HTTP Documentation says should be returned.
About Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
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!