尝试从 UWP 访问 OneDrive 根目录时出错

Error when trying to access OneDrive root from UWP

当我 运行 以下代码在调用请求时收到异常(消息:必须经过身份验证才能使用 '/drive' 语法):

private async Task<Item> GetRoot()
{
    var driveClient = 
        await OneDriveClientExtensions.GetAuthenticatedUniversalClient(
            new string[] { "files.readwrite", "offline_access" }
            );

    if (!driveClient.IsAuthenticated) return null;

    var itemRequest = driveClient.Drive.Root.Request();

    return await itemRequest.GetAsync();
}

我尝试使用覆盖 IHttpProvider 进行调试,我看到 GET 请求被发送到 https://api.onedrive.com/v1.0/drive/root,其中有两个 headers X-RequestStatsAuthorization 正确令牌。

我还在 https://account.live.com/consent/Manage 中检查了该应用的许可,我看到了 "Access OneDrive files" 和 "Access your info anytime" 权限。

我可能错过了一些基本的东西。请指教

谢谢

I also checked consent for the app in https://account.live.com/consent/Manage and I see "Access OneDrive files" and "Access your info anytime" permissions.

这是一个文档问题,文件。* 范围未正确注册 OneDrive Personal。

The document 已经恢复 到之前的版本,请使用 onedrive.readwrite 范围来确保您的应用按预期工作。

请参阅 onedrive-api-docs 存储库中的 this issue

It appears that the files.* scopes are not properly registered for OneDrive Personal. I've reverted the documentation to indicate you should use the onedrive.* scopes for OneDrive Personal. Please use the onedrive.readwrite scope to ensure your app works as expected.