当我运行以下代码时,我会在调用请求时收到异常(消息:必须通过身份验证才能使用'/ 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-RequestStats
和 Authorization
,带有正确的标记 .
我还检查了https://account.live.com/consent/Manage中应用程序的同意,我看到"Access OneDrive files"和"Access your info anytime"权限 .
我可能会错过基本的东西 . 请指教 .
谢谢
1 回答
这是 documentation issue ,文件 . *范围未正确注册OneDrive Personal .
The document已经 reverted 到先前版本,请使用 onedrive.readwrite 范围确保您的应用按预期工作 .
请参阅onedrive-api-docs存储库中的this issue