cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dropbox oath2/token returns undefined

Dropbox oath2/token returns undefined

TheKrominator
Explorer | Level 3
Go to solution

When I send my auth code it returns 'undefined'. I don't even get an error message.  I can set this up in Postman and get a response.

 

 

axios({
method : 'post',
url : 'https://api.dropboxapi.com/oauth2/token',
params :
{
code : request.body.code,
grant_type : 'authorization_code',
redirect_uri : 'http://localhost:9000/calback',
client_id : '###########',
client_secret : '##########'
},
headers : { "Content-Type" : "application/json" }
})
.then(function(req, res)
{
console.log(res)
response.send(JSON.parse(res));
})
.catch(function(error)
{
console.log(error);
response.status(500).send(error);
});

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

I just gave this a try and it looks like the Dropbox API itself is working properly.

 

I can't officially provide support for axios, but it looks like the issue is the callback function definition you're using. The axios client apparently just returns a single result variable, not a pair of `req, res` like you're trying to use. (And so, `res` isn't defined.)

 

So, you'll probably want to do something like this instead:

 .then(function(res) {
     console.log(res.data)
     // ...whatever you need to do with that here
 })

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

I just gave this a try and it looks like the Dropbox API itself is working properly.

 

I can't officially provide support for axios, but it looks like the issue is the callback function definition you're using. The axios client apparently just returns a single result variable, not a pair of `req, res` like you're trying to use. (And so, `res` isn't defined.)

 

So, you'll probably want to do something like this instead:

 .then(function(res) {
     console.log(res.data)
     // ...whatever you need to do with that here
 })

TheKrominator
Explorer | Level 3
Go to solution

That was it! I was reading the wrong response from the server.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    TheKrominator Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?