当我运行以下代码时,我在调用请求时收到异常(消息:必须经过身份验证才能使用“/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有两个 header X-RequestStats
和 Authorization
以及正确的 token 。
我还在https://account.live.com/consent/Manage中检查了对该应用程序的同意我看到“访问 OneDrive 文件”和“随时访问你的信息”权限。
我可能错过了一些基本的东西。请指教。
谢谢
最佳答案
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范围来确保您的应用按预期工作。
参见this issue在 onedrive-api-docs 存储库中
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.
关于c# - 尝试从 UWP 访问 OneDrive 根目录时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37374294/