Discuss Dropbox Developer & API
const parameters = {
'code': params.code,
'grant_type': 'authorization_code',
'redirect_uri': window.location.origin,
'client_id': dataApp.client_id,
'client_secret': dataApp.client_secret
}
console.log(parameters);
fetch('https://api.dropbox.com/oauth2/token', {
method: 'POST',
body: JSON.stringify(parameters)
}).then(response => console.log(response))
.catch(error => console.log(`Error in POST: ${error}`));
fetch('https://api.dropbox.com/oauth2/token', {
method: 'POST',
body: new URLSearchParams({
'code': params.code,
'grant_type': 'authorization_code',
'redirect_uri': window.location.origin,
'client_id': dataApp.client_id,
'client_secret': dataApp.client_secret
})
});
It looks like you're sending the parameters as JSON, but the /oauth2/token endpoint expects them as application/x-www-form-urlencoded POST parameters, and so your parameters aren't getting read. Update your implementation to send application/x-www-form-urlencoded POST parameters instead.
Check the contents of the response body for that error response. It should contain a more specific error message.
The request parameters do not match any of the supported authorization flows. Please refer to the API documentation for the correct parameters.
but I don't understand why if I used all the parameters from the documentation. At the same time, if you do it in сURL, everything will work out well
It looks like you're sending the parameters as JSON, but the /oauth2/token endpoint expects them as application/x-www-form-urlencoded POST parameters, and so your parameters aren't getting read. Update your implementation to send application/x-www-form-urlencoded POST parameters instead.
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!