1
votes

I'm super confused on how to create proper integrations from my web app to dropbox.

I want to list and create files from within the application. I'm using NodeJS and the Dropbox JS SDK, so far so good.

But I'm not understanding on how to set up the authentication/authorization.

I've created a Dropbox application, generated an API key. I pass the API Key in my call to the dropbox SDK:

var dbx = new Dropbox({
accessToken:
  "ABC_MY_KEY_123"
});
dbx
.filesListFolder({ path: "" })
.then(function(response) {
  console.log(response);
})
.catch(function(error) {
  console.log(error);
});

I'm getting the following error back:

status: 400, [0] error: 'Error in call to API function "files/list_folder": This API function operates on a single Dropbox account, but the OAuth 2 access token you provided is for an entire Dropbox Business team. Since your API app key has team member file access permissions, you can operate on a team member\'s Dropbox by providing the "Dropbox-API-Select-User" HTTP header or "select_user" URL parameter to specify the exact user https://www.dropbox.com/developers/documentation/http/teams

So, should my App have it's own user and then authenticate using that user?

Or is there an API which is Dropbox business wise ?

1

1 Answers

1
votes

When first registering a Dropbox app, you choose between either the "Dropbox API" or the "Dropbox Business API". The former will give you an app for connecting to individual user accounts, and the latter will give you an app for connecting to entire Business teams.

The filesListFolder method you're trying to use is a user-specific method, i.e., it operates on a specific user account, and not a Business team entirely.

The error message is indicating that your access token is for a Business team, and so it doesn't know which user to operate on.

If you want any user to connect to your app, you should register a "Dropbox API" app instead.

Or, if you do want to connect to entire Dropbox Business teams only (and selected the "team member file access" permission), you can still use the user endpoints with an access token for a Dropbox Business API app. To do so, you need to specify the desired member ID in the selectUser parameter when making your Dropbox object.