cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Re: 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?