I am using the Box V2.Core SDK to upload files through the API. I can successfully authenticate using JWT and read folder information as the service account, but when I attempt to upload a file I get the following error:
"Bearer realm="Service", error="insufficient_scope", error_description="The request requires higher privileges than provided by the access token.""
The Service Account is listed as a collaborator with editor permissions on the folder that I'm trying to upload to (my account is the middle co-owner and the service account is the bottom):
Here is an example of my code that is producing this error:
var configFilePath = Path.Combine(Directory.GetCurrentDirectory(), "boxconfig.json");
IBoxConfig boxConfig;
await using (var stream = File.OpenRead(configFilePath))
boxConfig = BoxConfig.CreateFromJsonFile(stream);
var auth = new BoxJWTAuth(boxConfig);
var token = auth.AdminToken();
var client = auth.AdminClient(token);
var request = new BoxFileRequest
{
Name = "test.jpg",
Parent = new BoxRequestEntity { Id = <myFolderId> },
};
// this source of a byte[] is just an example
var bytes = await File.ReadAllBytesAsync(<myFilePath>);
await using var stream = new MemoryStream(file);
// this line throws the insufficient_scope error
await client.FilesManager.UploadAsync(request, stream);
What am I missing? Shouldn't my service account have permission to perform this action?