My app is creating a file (DriveItem) using Graph API. It's using GraphServiceClient from Microsoft.Graph nuget and gets access token with ClientSecretCredential.
Here's the part when the file gets created:
public async Task CreateFile(string driveId, string folderId, string filename, byte[] content)
{
var driveItem = new DriveItem()
{
Name = filename,
File = new Microsoft.Graph.File()
{
MimeType = "application/pdf"
},
AdditionalData = new Dictionary<string, object>()
{
{ "@microsoft.graph.conflictBehavior", "rename" }
}
};
var response = await _client.Drives[driveId].Items[folderId].Children.Request().AddAsync(driveItem);
await _client.Drives[driveId].Items[response.Id].Content.Request().PutAsync<DriveItem>(new MemoryStream(content));
}
The problem is that the file that's created has the following createdBy identity set:
"createdBy": {
"application": {
"id": "[app-id]",
"displayName": "[app-display-name]"
},
"user": {
"displayName": "SharePoint App"
}
}
and the name shown in CreatedBy column when viewing files list in Teams is "SharePoint App" instead of my app's display name. When I try to manually set values for CreatedBy property and overwrite user's displayName it simply get ignored.
Am I missing something or is this by design and files created by apps ale always shown as created by "SharePoint App"?