[.NET] Service Account with Editor Permissions Getting access_denied_insufficient_permissions
I am using the Box V2.Core SDK to download files through the API. I can successfully authenticate using JWT and read folder information as the service account, but when I attempt to dowload a file I get the following error:
'The API returned an error [Forbidden | 89g04ghb3n0n6h63.06d6fafa0530b85581d0753287ee989fa] access_denied_insufficient_permissions - Access denied - insufficient permission'
The service account is listed as a collaborator with editor permissions in the folder
Here is the associated app id for the service account: 1937532
Here is sample code for what we're doing:
var config = BoxConfigBuilder.CreateFromJsonString(jsonConfig).Build();
var session = new BoxJWTAuth(config);
var adminToken = await session.AdminTokenAsync();
BoxClient adminClient = session.AdminClient(adminToken);
BoxCollection<BoxItem> folderItems = await adminClient.FoldersManager.GetFolderItemsAsync(folderId, 100);
var fileName = "Report 1" + ".csv";
var filePath = "/folder1/";
folderItems.Entries.ForEach(async folder =>
{
if (string.Equals(folder.Name, "SHARED_FOLDER_NAME", StringComparison.OrdinalIgnoreCase))
{
BoxCollection<BoxItem> settlementFiles = await adminClient.FoldersManager.GetFolderItemsAsync(folder.Id, 1000);
settlementFiles.Entries.ForEach(async settlementFile =>
{
if (string.Equals(settlementFile.Name, fileName, StringComparison.OrdinalIgnoreCase))
{
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
var FileName = Path.Combine(filePath, fileName);
Stream fileContents = await adminClient.FilesManager.DownloadAsync(settlementFile.Id);
Wondering what I could be missing here? Thanks!
-
hmm.... can you try reauthorizing the application in the admin console and try again?
サインインしてコメントを残してください。
コメント
1件のコメント