Searching for owner of folder through API
I have a .Net WPF application and am using the Box V2 SDK. I have an app that is authenticating using a bearer token.
I get through the authenitcation and authorize box through a browser. once that is done, I am attempting to search for a folder.
here is the relevant code:
var results = await client.SearchManager.QueryAsync("Accounts Payable");
var userClient = new BoxClient(config, session, asUser: "user@domain.com"); //actual user redacted
var userResults = await userClient.SearchManager.QueryAsync("Accounts Payable", type: "folder");
results will return about 7 results. all are of type file, and Im looking for a folder. userResults returns an error that the user cannot be found. this is the same user that I am authorizing the app through box. what I am really trying to do is search for a folder (we have the full folder path) and get the current owner. is that possible?
-
Hi Keven,
I was trying to replicate your issue but I need some more info.
When you mentioned "this is the same user that I am authorizing the app through box" I think of an OAuth 2 app with user or client authentication.
Although it is possible to make API calls using the as-user header:
The authenticated user must have admin permissions, see here.
Are you trying to find a folder owned by another user, not the authenticated one? The sharing permissions are still enforced.
The as-user is more common in a JWT application, which has its own service user and then can "impersonate" another user, take a look here.
Let us know if this helps.
-
thank you for the response. I have a couple apps that all are atempting to do the same thing.
I have an app that uses JWT, but got 0 search results on anything but the root
I have an app that uses Oauth2 with Client Grant
and this app that uses user auth. I have the check box checked for using the as-user header. and the user that I am passing in is an admin.
to your question "Are you trying to find a folder owned by another user, not the authenticated one?" that is correct. I am using an admin account to find a folder and retrieve the current owner of it.
"The sharing permissions are still enforced." does this mean that I have to have the folder shared to me in order to see it in a query? if so, how can I accomplish the following:
I would like to search for a folder by name, using an admin account, and retrieve its current owner.
I can do this through the website using the admin credentials. I would like to do it programmatically.
-
Hi Keven!
To find a folder by name, you need to use our Search API. You also would need to run the command with an as-user header if you are looking for content that is not owned or not collaborated with the user you are using to run the command. The admin doesn't have blanket access to search all content in an organization unless that are collaborated in or own all content.
There's not a way to find out who owns a folder programmatically if you don't have access to the content.
By "I can do this through the website..." what do you mean exactly?
Thanks,
Alex, Box Developer Advocate
投稿コメントは受け付けていません。
コメント
3件のコメント