Box JWTOauth App User - 404 error
I am new to Box development.
I created app user using JWT Oauth. When I try to upload file or create folder, I get 404 error message. Basically app is not having access to folder. I am not sure where exactly I should grant access
-
var session = new BoxJWTAuth(BoxConfig.CreateFromJsonFile(fs));
var serviceAccountClient = session.AdminClient(session.AdminToken());
// Use the GetCurrentUserInformationAsync method to retrieve current user's information.
// Since this client uses the Service Account, this will return the Service Account's information.
var serviceAccountUserInfo = await serviceAccountClient.UsersManager.GetCurrentUserInformationAsync();
// Log the Service Account's login value which should contain "AutomationUser".
// For example, ***email address removed for privacy***
Console.WriteLine(serviceAccountUserInfo.Login);
var adminToken = session.AdminToken();
Console.WriteLine("Admin Token: " + adminToken);
Console.WriteLine();
var adminClient = session.AdminClient(adminToken);
//var userRequest = new BoxUserRequest() { Name = "test appuser", IsPlatformAccessOnly = true };
//var appUser = await adminClient.UsersManager.CreateEnterpriseUserAsync(userRequest);
//adminClient.UsersManager.GetEnterpriseUsersAsync
Console.WriteLine("Created App User");
var userToken = session.UserToken("***number removed for privacy***4");
var userClient = session.UserClient(userToken, "***number removed for privacy***4");
var userDetails = await userClient.UsersManager.GetCurrentUserInformationAsync();
Console.WriteLine("\nApp User Details:");
Console.WriteLine("\tId: {0}", userDetails.Id);
Console.WriteLine("\tName: {0}", userDetails.Name);
Console.WriteLine("\tStatus: {0}", userDetails.Status);
Console.WriteLine("\tLogin: {0}",userDetails.Login);
-
I created user and then I had to grant permission to that user to the Box folder. And use the User ID to get user and then I was able to upload the file. Not sure if this is the right way to do. I was thinking the user created through app will automatically have access same as the app.
Please sign in to leave a comment.
Comments
3 comments