One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
TheKrominator
5 years agoExplorer | Level 3
Dropbox Bearer token is too short
When I log in to DropBox, I get approved and receive my auth token. But, the token is too short!
I should receive : "################################-###############################"
but I get : "###################-#######################"
This returns a "invalid_access_token" error.
Below is my layout for passport-dropbox-oauth2:
app.get('/dropboxLogin', passport.authenticate('dropbox-oauth2'));
app.get('/auth/dropbox/callback',
passport.authenticate('dropbox-oauth2', { failureRedirect: '/' }),
function(req, res)
{
// Successful authentication, redirect home.
res.render('index', { title:'Dropbox Login', body:res});
});
app.get('/loggedIn', function(req,res)
{
//have bearer token
let token = req.query.code;
console.log(req.query);
res.redirect('/Callback/?token='+token);
});
It sounds like you're using the "code" flow, so Dropbox will return an "authorization code", not an access token. When using the code flow, once you receive the authorization code, you need to then exchange it for an access token using /oauth2/token.
Check out the /oauth2/authorize and /oauth2/token documentation for more information on how this works.
- Greg-DB
Dropbox Staff
It sounds like you're using the "code" flow, so Dropbox will return an "authorization code", not an access token. When using the code flow, once you receive the authorization code, you need to then exchange it for an access token using /oauth2/token.
Check out the /oauth2/authorize and /oauth2/token documentation for more information on how this works.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,953 PostsLatest Activity: 4 months ago
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!