Accessing another user's drive using the OneDrive SDK

混江龙づ霸主 提交于 2019-12-25 04:29:11

问题


I can't figure out the proper syntax to open another user's OneDrive folder. What am I doing wrong? The parameter is supposed to be "ID", but is that a user ID/name, a drive ID - what? Below is some pseudo-code, based on the OneDrive API Browser sample.

I get this error: "The provided drive id appears to be malformed, or does not represent a valid drive."

private async Task LoadUserDriveTest()
{
    Item folder;
    var expandValue = "thumbnails,children";

    folder =
        await oneDriveClient
        .Drives[$"user_mydomain_onmicrosoft_com"]
        .Root
        .Request()
        .Expand(expandValue)
        .GetAsync();
    //Code: invalidRequest
    //Message: The provided drive id appears to be malformed, or does not represent a valid drive.
}

回答1:


For a drive identifier, you can use any of these:

  • User's UPN address (usera@mydomain.onmicrosoft.com)
  • User's object ID in AAD (guid)
  • DriveID previously obtained by other means (say, by having a shared item return a parentReference property with a driveID).

You'd think I would have documented that here, but apparently I need to do some more writing.



来源:https://stackoverflow.com/questions/40232058/accessing-another-users-drive-using-the-onedrive-sdk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!