Search code examples
c#windows-phone-8.1windows-phoneonedrive

OneDrive SDK windows phone 8.1 permisions to upload file


I'm developing an aplication for Windows Phone 8.1 which is synchronized with OneDrive. I'm using OneDrive sdk API.

In my phone (and my OneDrive acc) I'm able to edit, delete, rename and SAVE files. My friend is testing this app and app working well but he CAN'T SAVE the files. After Click to save button application crash with unexpected error. We are trying it on the same files so I don't know why it works on my OneDrive and on my friends OneDrive not.

Does OneDrive has some security settings ?

My authentication code (via https://github.com/OneDrive/onedrive-sdk-csharp/blob/master/docs/auth.md )

 var oneDriveClient = OneDriveClientExtensions.GetClientUsingOnlineIdAuthenticator(scopes);
 await oneDriveClient.AuthenticateAsync();

Here is my upload code

MemoryStream stream = new MemoryStream();
                StreamWriter writer = new StreamWriter(stream);
                writer.Write(UploadString);
                writer.Flush();
                stream.Position = 0;

 var itemWithUpdates = await oneDriveClient
                                            .Drive
                                             .Items[Id]
                                          .Content
                                 .Request()
                                 .PutAsync<Item>(stream);

Solution

  • Problem was in scopes. For update items you need add to scopes "wl.skydrive_update"

    String[] scopes = { "wl.signin", "wl.skydrive","wl.skydrive_update"};
                var oneDriveClient = OneDriveClientExtensions.GetClientUsingOnlineIdAuthenticator(scopes);
    
                await oneDriveClient.AuthenticateAsync();