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}`));
params.code - this is code when i first redirect to my http in url parameters
window.location.origin - origin url my web-site
dataApp.client_id - Api Key my application
dataApp.client_secret - App secret my application
But when fetching my response 400 - why?
I looked at the curl convenerator in js suggested to do this
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
})
});
But this again not work

