cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Find out how Tiffany, a Customer Experience superstar uses Dropbox to keep her family in the loop when it comes to her new baby 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

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

Re: Dropbox oath2/token returns undefined

Greg-DB
Dropboxer

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

Re: Dropbox oath2/token returns undefined

Greg-DB
Dropboxer

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

Re: Dropbox oath2/token returns undefined

TheKrominator
Explorer | Level 3

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

Who's talking

Top contributors to this post

  • User avatar
    TheKrominator Explorer | Level 3
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?