cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out more 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: Creating an integration for both Regular and Business users

Creating an integration for both Regular and Business users

JimmyMcnulty
New member | Level 2
Go to solution

I created a Dropbox app that allows users to upload files into my app. All was well until I realized, that users with Dropbox for Business can't import files, because I needed different scopes for them, and a different flow in my backend code (endpoints, headers etc).

Currently, to the best of my knowledge after researching the topic - scoped apps can't support both Regular and Business users. It seems that only legacy apps, pre scopes, are capable of that.

 

Am I going to have to create two apps for my users - one for Regular users, and one for Business users?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Yes, that's correct. Using the 'pathRoot' property sets the "Dropbox-API-Path-Root" header; if you use the "root" mode like that and set it to the account's root_namespace_id that would set the call to operate in the root for the account (such as the team space, if any).

View solution in original post

7 Replies 7

Здравко
Legendary | Level 20
Go to solution

@JimmyMcnulty wrote:

I created a Dropbox app that allows users to upload files into my app. ...

Am I going to have to create two apps for my users - one for Regular users, and one for Business users?


Hi @JimmyMcnulty,

No, as far as you only need to upload some files. All actions for file management that particular user has access to require only user scopes, not team scopes for both individual and team accounts. The only thing you may need to manage in addition is the default namespace change. In all cases by default Dropbox API access user home namespace if not changed. For individual users, that's the account root - they just coincide. For team member though, it's their home folder that may be or not account root. In this context, you may need to change API namespace to the account root if desirable (set Dropbox-API-Path-Root or use appropriate method of official SDK). That's it - nothing more.

You need team scopes only if you need to manage member access and other admin tasks in addition to just files upload, otherwise no.

Hope this clarifies matter.

JimmyMcnulty
New member | Level 2
Go to solution

Thanks for the reply Zdravko.

 


I'm not entirely sure about what you're saying - If I want to list files from a team folder, I have to make the call with Dropbox-API-Select-User and also supply the namespace, if it's not under the root namespace. 


Case in point - I am using the Chooser popup, and if you select files as a Business user, the integration doesn't work because it expects Dropbox-API-Select-User.

Здравко
Legendary | Level 20
Go to solution

@JimmyMcnulty wrote:

...
Case in point - I am using the Chooser popup, and if you select files as a Business user, the integration doesn't work because it expects Dropbox-API-Select-User.


Ha..🤔 Chooser doesn't expect anything to set - it's even impossible. I have an simplistic player example here. There has nothing like additional headers set. Check and see, if you have any issue to play some audio file on any account. 😉

 


@JimmyMcnulty wrote:

... and also supply the namespace, if it's not under the root namespace. 

...


No, you need to supply namespace if the point you want to access is outside member home folder! It's different thing - take a bit more care. 😉 If you have already access to the account root (it's possible in some old accounts) you don't need to change anything, instead in such a case you may upload in the same way as on individual account.

 

PS: By the way, you don't need to set user explicitly if no team scope has been  added!!! As seems you make your life difficult on your own. 🙂 You may take a look on upload example using Dropbox Saver - again it's working on any account type.

Greg-DB
Dropbox Staff
Go to solution

@JimmyMcnulty To confirm, Здравко is correct; you can and should use the same user scopes on a single app with the same files endpoints to work with files in both business and non-business accounts. You don't need team scopes to work with files in accounts that happen to be on business teams. For example, to upload files, you would use the same /2/files/upload endpoint which only requires the "files.content.write" user scope, whether or not the user is a on a team. (You would only need team scopes to perform operations on the team, such as to add/remove team members.)

 

One difference though is that by default, API calls to the Dropbox API operate in the "member folder" of the connected account, not the "team space". That means that by default, the contents of the team space will not be found and uploads will go to the member folder, not the team space. You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space. To do so, you'll need to set the "Dropbox-API-Path-Root" header, but you can still do so without team scopes. You can find information on how to use this in the Team Files Guide.

JimmyMcnulty
New member | Level 2
Go to solution

Thanks for the reply Greg.

 


I think I managed to have a small breakthrough after your explanation:

 

new Dropbox({
  accessToken,
  pathRoot: JSON.stringify({ ".tag": "root", root: "XXX" })
});
 
In this example, I'm assuming this will always work, as long as I pass 
root_namespace_id from /2/users/get_current_account, is that correct?

Здравко
Legendary | Level 20
Go to solution

@JimmyMcnulty wrote:
... I pass 
root_namespace_id from /2/users/get_current_account, is that correct?

In general yes, but better check if the root namespace is different that home namespace and use the above only when they are different. In such a way your code becomes universal - will work everywhere on any account. 😉

Greg-DB
Dropbox Staff
Go to solution

Yes, that's correct. Using the 'pathRoot' property sets the "Dropbox-API-Path-Root" header; if you use the "root" mode like that and set it to the account's root_namespace_id that would set the call to operate in the root for the account (such as the team space, if any).

Need more support?