首页 文章

尝试从UWP访问OneDrive根时出错

提问于
浏览
2

当我运行以下代码时,我会在调用请求时收到异常(消息:必须通过身份验证才能使用'/ 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,带有两个标头 X-RequestStatsAuthorization ,带有正确的标记 .

我还检查了https://account.live.com/consent/Manage中应用程序的同意,我看到"Access OneDrive files"和"Access your info anytime"权限 .

我可能会错过基本的东西 . 请指教 .

谢谢

1 回答

  • 2

    我还在https://account.live.com/consent/Manage中检查了对该应用程序的同意,我看到“Access OneDrive文件”和“随时访问您的信息”权限 .

    这是 documentation issue ,文件 . *范围未正确注册OneDrive Personal .

    The document已经 reverted 到先前版本,请使用 onedrive.readwrite 范围确保您的应用按预期工作 .

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

    似乎没有为OneDrive Personal正确注册文件 . *范围 . 我已经恢复了文档,表明你应该使用OneDrive Personal的onedrive . *范围 . 请使用onedrive.readwrite范围确保您的应用按预期工作 .

相关问题