cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App 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: 

Simple Node script not working with clientId /secret

Simple Node script not working with clientId /secret

rdyar
Helpful | Level 5

I'm trying to do the worlds simplest node dropbox script but getting an error, clearly I am missing something.

 

I set up an App - and gave it all the read permissions.

 

Then I have this script which should list the contents of the root - which I assume would be the App folder name I setup:

 

```

import { Dropbox } from "dropbox";
import fetch from "node-fetch";

const clientId = "***";
const clientSecret = "***";

const config = {
  fetch,
  clientId,
  clientSecret,
};
const dbx = new Dropbox(config);

dbx
  .filesListFolder({ path: "" })
  .then((response) => {
    const entries = response.result.entries;
    console.log("Contents of the root directory:");
    entries.forEach((entry) => {
      console.log(entry.name);
    });
  })
  .catch((error) => {
    console.error("Error listing contents:", error);
    if (error.response) {
      console.error("Error response:", error.response.data);
    }
  });

```

 

I have the correct id and secret entered when I run it, not ***

 

When I run it I get an error:

```

Error listing contents: DropboxResponseError: Response failed with a 409 code
at D:\Repos\locket-emailer\node_modules\dropbox\cjs\src\response.js:34:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
status: 409,
headers: {
'accept-encoding': 'identity,gzip',
'cache-control': 'no-cache',
connection: 'close',
'content-length': '126',
'content-security-policy': 'sandbox allow-forms allow-scripts',
'content-type': 'application/json',
date: 'Sat, 23 Dec 2023 03:34:45 GMT',
server: 'envoy',
'x-content-type-options': 'nosniff',
'x-dropbox-request-id': '266f5a0735ac4753a45ad1bb0214e9c5',
'x-dropbox-response-origin': 'far_remote'
},
error: {
error_summary: 'path/unsupported_content_type/..',
error: { '.tag': 'path', path: [Object] }
}
}

```

 

Shouldn't this work? I read in another thread that the app permissions don't allow access to anything but in another place I read I should be able to access the apps folder which makes more sense to me.

 

All I want to end up with is a script I will run on a local computer on a schedule to get some shareable links - for my own files which will be in the apps folder.

10 Replies 10

Greg-DB
Dropbox Staff

@rdyar If you're using an official Dropbox SDK, like the official Dropbox JavaScript SDK you're using in the last piece of code you shared, you don't need to perform the "grant_type=refresh_token" step yourself. If you pass the necessary credentials (refresh token and app key/secret) to the SDK, it will automatically handle that refresh process for you.

 

Also, when using filesListFolder, be sure to implement filesListFolderContinue as well. Check out the documentation there for more information.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    rdyar Helpful | Level 5
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?