GithubHelp home page GithubHelp logo

Comments (13)

cdmayer avatar cdmayer commented on July 29, 2024 1

I apologize for misrepresenting the API. Even I did not know that was possible! I updated the comment above.

from onedrive-sdk-csharp.

nsouren avatar nsouren commented on July 29, 2024

Any news on this question?

from onedrive-sdk-csharp.

ginach avatar ginach commented on July 29, 2024

You can access another drive using client.Drives[driveId]. As long as the authenticated caller has access to the drive ID then the call should succeed.

from onedrive-sdk-csharp.

elegault avatar elegault commented on July 29, 2024

Is DriveID the user name? I've got a user with a OneDrive URL like this: https://mydomain-my.sharepoint.com/personal/usera_mydomain_onmicrosoft_com/Documents. And code like this (simplified for brevity), but it throws an exception:

` private async Task LoadUserDriveTest()
{
Item folder;

        var expandValue = "thumbnails,children";

        folder = await oneDriveClient.Drives[$"usera_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.
    }`

from onedrive-sdk-csharp.

cdmayer avatar cdmayer commented on July 29, 2024

The DriveId is a string that uniquely identifies the drive.

The code you provided is not valid. Drives[{driveId}] expects a DriveId, user account (email address), or AAD Object ID. Additionally, you can instead use the extension OneDriveClient.Drive which is a shortcut to basically say "the drive of the signed-in user." If you want to access a drive other than the signed-in user, you need to first know the target user's DriveId. You can find out a user's DriveId using this simple call:

var drive = await oneDriveClient.Drive.Request().GetAsync();
var driveId = drive.Id;

[Edited for correctness]

from onedrive-sdk-csharp.

elegault avatar elegault commented on July 29, 2024

Actually, @rgregg guided me to use the SMTP address of the user as the drive ID - and it works! e.g. folder = await oneDriveClient.Drives["[email protected]"].Root.Request().Expand(expandValue).GetAsync();

from onedrive-sdk-csharp.

elegault avatar elegault commented on July 29, 2024

I've been testing this approach heavily over the weekend, and it appears flakey or some user's drives just cannot be accessed for some reason (the permissions are good). I've been seeing this error:

Code: invalidRequest Message: The provided drive id appears to be malformed, or does not represent a valid drive.
HResult: -2146233088

This has happened consistently for a certain set of users, and for two users it failed but then subsequently worked with a second or third attempt.

I will try your approach with the drive ID to see if it works - would this be the call: oneDriveClient.Drives["[email protected]"].Request().GetAsync()

from onedrive-sdk-csharp.

elegault avatar elegault commented on July 29, 2024

I tried using the Drive ID approach - it only worked for one of the users where it failed by using their email address. I will see if I can get the AAD object ID for the users where it is failing. Otherwise any guidance would be super appreciated! This is a super high-priority project and I'm going to look bad if I can't process a high percentage of users. :-( /cc @rgregg

from onedrive-sdk-csharp.

rgregg avatar rgregg commented on July 29, 2024

Hey Eric: Can you reach out to me directly? (rgregg -at- microsoft.com).

For failed calls, if you can send me the request ID, the date/time the request was made, and the tenant you were using, I can look up the details and sort out why you're getting that error and if we have a bug hiding or something else.

Also, just to make sure, you need to use the UPN, not a user's email address (most of the time they're the same, but not always).

from onedrive-sdk-csharp.

elegault avatar elegault commented on July 29, 2024

Me again, talking into the wind lol! Turns out it was a permissions issue - the admin account was only granted the Application Impersonation Role. This apparently adds the account to the user's Site Collection Admins, but the issues went away when he added the admin account manually.

from onedrive-sdk-csharp.

rgregg avatar rgregg commented on July 29, 2024

That's good to hear. Sounds like we could use a better error state though for that scenario.

from onedrive-sdk-csharp.

elegault avatar elegault commented on July 29, 2024

BTW, my apologies for totally missing your reply. I've been overcoding and need some sleep! Thanks Ryan

from onedrive-sdk-csharp.

jaycdave88 avatar jaycdave88 commented on July 29, 2024

Is there a way to grant permissions to manage a custodian user's OneDrive through the SDK? I created a SO on the question as well which has more context.

http://stackoverflow.com/questions/42012975/access-files-for-custodian-account-from-admin-account-onedrive-sdk-csharp-is-th

from onedrive-sdk-csharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.