I have the following console application code and I'm seeing that with the developer token I can see all files and folders. But the App Users that I create cannot see anything. Anyone have a sample that downloads a file using the .Net SDK?
Do I need to create a user manually and assign permissions? I've seen alot of the same problems in other posts but I've not seen a solution yet...
Code:
try
{
// from https://github.com/box/box-windows-sdk-v2
var config = ConfigureBoxApi();
var boxJWT = new BoxJWTAuth(config);
// create a Admin Client with permissions to manage app users
var adminToken = boxJWT.AdminToken();
var adminClient = boxJWT.AdminClient(adminToken);
// Create an App User
var userRequest = new BoxUserRequest() { Name = "test appuser", IsPlatformAccessOnly = true };
var appUser = await adminClient.UsersManager.CreateEnterpriseUserAsync(userRequest);
Console.WriteLine("New app user created with Id = {0}", appUser.Id);
// user client with access to user's data (folders, files, etc)
string appUserToken = boxJWT.UserToken(appUser.Id); //valid for 60 minutes so should be cached and re-used
var appUserClient = boxJWT.UserClient(appUserToken, appUser.Id);
// Root folder shows Zero child items with the created appUser?????
var boxRootFolderItems = await appUserClient.FoldersManager.GetInformationAsync("0");
List boxFolderItemsList = boxRootFolderItems.Entries;
foreach (BoxItem item in boxFolderItemsList)
{ // Nothing? ...
Console.WriteLine("Item Name: {0}. Item Id: {1}", item.Name, item.Id);
}
}
catch (Box.V2.Exceptions.BoxException boxEx)
{
Console.Write(boxEx.Message);
}