图 API Onedrive approot 创建为 "Microsoft Graph"

Graph API Onedrive approot created as "Microsoft Graph"

我在应用程序注册门户中注册了我的应用程序,并在 Microsoft Graph 权限中设置应用程序权限以获取 Files.ReadWrite.All(仅限管理员)。这样我就可以使用管理员同意获得对组织中所有用户的访问权限。

使用我获得的令牌,我可以毫无问题地调用 API 个端点。

然后我尝试访问特定用户的 approot。我向

发送了 GET 请求
https://graph.microsoft.com/v1.0/users/{UPN}/drive/special/approot

根据 documentation,当我调用端点时,它应该在用户 OneDrive 的 Apps 文件夹内创建一个文件夹,使用我在应用程序注册门户中注册的应用程序的名称。

问题是创建的文件夹的名称是 "Microsoft Graph" 而不是我的应用程序名称。

如何使用我的应用程序名称创建应用程序文件夹?

您需要申请Files.ReadWrite.AppFolder。来自 documentation:

The App Folder is a dedicated, special folder for your app. The App Folder is typically named after your app, and is found in the Apps folder in the user's OneDrive. If you request the Files.ReadWrite.AppFolder permission scope and the user authorizes it, your app gets read and write access to this folder.

还值得注意的是 Files.ReadWrite.AppFolder 仅适用于个人帐户 (OneDrive),不适用于 Work/School 帐户 (OneDrive for Business)。来自 Permissions documentation:

The Files.ReadWrite.AppFolder delegated permission is only valid for personal accounts and is used for accessing the App Root special folder with the OneDrive Get special folder Microsoft Graph API.

顺便说一句,这里的文档确实令人困惑,有时似乎自相矛盾。我在文档库中打开了一个问题,看看是否可以更好地解决许可主题。