We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
jraymonds
2 years agoExplorer | Level 4
Trouble enumerating directories in a team space with SwiftyDropbox on macOS
I know this is a newbie issue but I cannot seem to find the right track to get over this learning curve... I can successfully authenticate on macOS to this point: let client = DropboxClients...
- 2 years ago
jraymonds First, you should decide if you need your app to be linked to the team or linked to the user. When you use any "team scopes", the app would be linked to the entire team itself. If you don't use any team scopes, the app would be linked to the user account only.
If you only need access to user functionality, such as things under FilesRoutes like listFolder/listFolderContinue, it would be best to not enable any team scopes and only use user scopes. That way, the app gets linked to the account and doesn't have unnecessary access to team operations. It would also mean that you don't need to specify the member ID, as its only connected to one account anyway.
Also, whether the app is team-linked to user-linked, you would use DropboxClient.withPathRoot to set the Dropbox-API-Path-Root header if you need to access the team space. Accessing the team space that an connected account has access to doesn't require team scopes. Check out the Team Files Guide for more context on accessing the team space.
You can call getCurrentAccount on UsersRoutes using a DropboxClient.
So, for a user-linked app, you could do something like this:
// DropboxClientsManager.authorizedClient is a DropboxClient DropboxClientsManager.authorizedClient!.users.getCurrentAccount().response { response, error in if let account = response { let rootNamespaceId = account.rootInfo.rootNamespaceId // this gets the root namespace ID for the account, which is the team space if the account has a team space DropboxClientsManager.authorizedClient = DropboxClientsManager.authorizedClient!.withPathRoot(Common.PathRoot.root(rootNamespaceId)) // this sets the root for the client to the root found above, e.g., the team space DropboxClientsManager.authorizedClient!.files.listFolder(path: "").response { response, error in if let listing = response { print(listing) } else { print(error!) } } // and so on, handling the result and calling listFolderContinue as needed } else { print(error!) } }
Alternatively, if you do need the app to be team-linked for whatever reason, you would get a DropboxClient from asMember on DropboxTeamClient. You can get a member ID from other methods like tokenGetAuthenticatedAdmin, membersGetInfoV2, membersListV2/membersListContinueV2, etc. on TeamRoutes.
Здравко
2 years agoLegendary | Level 20
Hi jraymonds,
What about using getCurrentAccount() (or /2/users/get_current_account)? 🧐 The info there - teamMemberId - may be more useful about the "me". 😉
jraymonds wrote:... First, since this is an in-house app in a controlled space do I need to worry about member IDs changing? ...
Every user has its own member id that doesn't change. So, if you mean is this id changes - clearly No. If you mean is it stay the same for any member in your account - definitely No.
jraymonds wrote:... Or, would it be "safe" to just hard code the ID when I know what it actually is? ...
Are you the only member for your account would use that application? 🤔 Yes -> Yes. No -> No.... Generally it's not a good idea. Let's say if at some moment you decide to change your member representation, for instance - What's going on? 👈🙋 You have to edit your application every time. 😁
jraymonds wrote:... Second, I am looking to enumerate the team space the account has access to and not their personal space. I believe I also saw references to differentiate between these roots once I have access. How should that part be handled?
There is info too about the account's root namespace and member's home namespace; just ignore (jump over) your home namespace while enumerating. 😉 That's it.
Hope this helps.
- jraymonds2 years agoExplorer | Level 4
I actually tried to figure out:
getCurrentAccount()
However, I guess my issue is I do not know where to access it from. It is not part of the DropboxClientsManager, Team, or even the DropboxClientsManager.authorizedTeamClient classes. I know I am missing something dumb on this but I cannot seem to figure it out.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,878 PostsLatest Activity: 2 hours agoIf 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!