We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
Boneless
4 years agoHelpful | Level 6
How to get team root folder by SwiftyDropbox?
Hi Dropbox Forum,
I want to get team root folder by SwiftyDropbox. but fail.
this is what I do
1.Set .plist file
2.Set AppKey in AppDelegate
DropboxClientsManager.setupWithA...
- 4 years ago
Thank you!
We solved the problem of setting "withPathRoot" by SwiftyDropbox.
For other people has the same problem, I record what I do here.
I set class variable as you said(Most important).
var dropboxClient:DropboxClient?
login then do those things
dropboxClient = DropboxClientsManager.authorizedClient dropboxClient?.users.getCurrentAccount().response(completionHandler: {user, error in let rootNamespaceId = user?.rootInfo.rootNamespaceId if rootNamespaceId != nil{ self.dropboxClient = DropboxClientsManager.authorizedClient?.withPathRoot(.namespaceId(user?.rootInfo.rootNamespaceId ?? "")) } self.dropboxClient?.files.listFolder(path: self.filePath).response(completionHandler: {response, error in //Parse if response?.entries != nil{ self.parseDropboxEntries(entries: response!.entries) } }) })
Boneless
Helpful | Level 6
Thank for your reply.
If I open any Team Scopes and use DropboxClientsManager.authorizeFromController, When my app jump to the Dropbox app forauthorize, it will show error message.
Spoiler
Error loading app info
An unknow error occurred
If I close all Team Scopes and don't set withPathRoot.
let client = DropboxClientsManager.authorizedClient?.withPathRoot(.namespaceId("xxxxxx"))
I can successful get "member folder" (purple) ,but I want to get "team folders" (blue)
Please tell me how to solve this error, thank you :sob:
Greg-DB
4 years agoDropbox Staff
The "Error loading app info" can occur if you attempt to request scopes that are not enabled for your app. It sounds like your app does not have team scopes enabled, so you should not request them.
You should use withPathRoot to access the team space though. Can you check that you are doing so, and that your "xxxxxx" value is the root namespace ID for the team space? What error/output are you getting for that now?
- Boneless4 years agoHelpful | Level 6
Let focus on the first question “team scopes”
I set a new app in App Console and create a simple test project for it.
You can see the code here
https://github.com/hanpo/XenBoxTest
You also can see my setting in App Console by images.
If I use ScopeRequest(scopeType: .user, scopes: ["account_info.read"], includeGrantedScopes: false) or DropboxClientsManager.authorizeFromController, it will show "Error loading app info"
The test project may let you clearly point where I am doing wrong for authoriztion.
Thank you!
- Greg-DB4 years agoDropbox Staff
I see, thanks! That's helpful. I see in this sample project that you're requesting a team scope "team_info.read", and it sounds like you have the official Dropbox iOS app installed. When you have the official Dropbox mobile app installed, it will handle the app authorization flow (since the user is likely already signed in there anyway). Unfortunately, it looks like the authorization flow in the official mobile apps doesn't currently work with team scopes in particular though. (I'll bring this up with the team to see if we can get that working.)
If you just want to list the contents of any folders (including team folders/spaces) in the user's account though, you don't actually need any team scopes. You just need 'files.metadata.read' (a user scope) to be able to access the metadata of any folder/space in the connected account.
So, please just use the user scopes (such as 'files.metadata.read') and let me know what trouble, if any, you're still having with listFolder/listFolderContinue. Thanks!
- Boneless4 years agoHelpful | Level 6
OK, Team Scopes is all close and only open Individual Scopes.
Then I modify code and commit it for getting team root folders and files.
You can see the code here
https://github.com/hanpo/XenBoxTestOperation is use method loginAction then call method listAction
In method listAction
let clientWithPathRoot = DropboxClientsManager.authorizedClient?.withPathRoot(.namespaceId(rootNamespaceIdString ?? "")) clientWithPathRoot?.files.listFolder(path: "" ,includeMountedFolders: true).response(completionHandler: {response, error in print("response:\(response),error:\(error) ") })
I think clientWithPathRoot maybe not get correct object.
So, when listFolder will show error
Spoiler2021-02-04 12:08:26.656055+0800 XenBoxTest[2036:1742155] Task <845DD768-5EDB-4121-A43B-96302CBCE75F>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://api.dropbox.com/2/files/list_folder, NSErrorFailingURLKey=https://api.dropbox.com/2/files/list_folder, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <845DD768-5EDB-4121-A43B-96302CBCE75F>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <845DD768-5EDB-4121-A43B-96302CBCE75F>.<1>, NSLocalizedDescription=cancelled} [-999]
2021-02-04 12:08:26.666504+0800 XenBoxTest[2036:1742152] Task <845DD768-5EDB-4121-A43B-96302CBCE75F>.<1> finished with error - code: -999
2021-02-04 12:08:26.670393+0800 XenBoxTest[2036:1742153] Task <845DD768-5EDB-4121-A43B-96302CBCE75F>.<1> HTTP load failed (error code: -999 [1:89])
response:nil,error:Optional(Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://api.dropbox.com/2/files/list_folder, NSErrorFailingURLKey=https://api.dropbox.com/2/files/list_folder, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <845DD768-5EDB-4121-A43B-96302CBCE75F>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <845DD768-5EDB-4121-A43B-96302CBCE75F>.<1>, NSLocalizedDescription=cancelled})
Any suggestion? thank you
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,878 PostsLatest Activity: 9 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!