You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

TheKrominator's avatar
TheKrominator
Explorer | Level 3
5 years ago

Dropbox oath2/token returns undefined

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);
});

  • 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
     })
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    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's avatar
      TheKrominator
      Explorer | Level 3

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

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,889 PostsLatest Activity: 4 hours ago
327 Following

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 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!