Meir Pletinsky
Meir Pletinsky

Reputation: 93

Error when trying to access OneDrive root from UWP

When I run the following code I receive exception (message: Must be authenticated to use '/drive' syntax) on invoking the request:

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();
}

I tried to debug using override for IHttpProvider and I see GET request is sent to https://api.onedrive.com/v1.0/drive/root with two headers X-RequestStats and Authorization with correct token.

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.

I probably miss something basic. Please advise.

Thanks

Upvotes: 2

Views: 526

Answers (1)

Franklin Chen - MSFT
Franklin Chen - MSFT

Reputation: 4923

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.

This is a documentation issue, the files.* scopes are not properly registered for OneDrive Personal.

The document has been reverted to previous version, please use the onedrive.readwrite scope to ensure your app works as expected.

See this issue in onedrive-api-docs repository

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.

Upvotes: 2

Related Questions