I've been all through Microsoft's website trying to find CURRENT documentation for implementing the ability for users to connect to their Microsoft account so that their information can be automatically synced with their OneDrive account. On the website they keep directing me to a page that only supports Windows 8.1 and Windows Phone 8.1. There is absolutely NO documentation specific to UWP apps.
I can go on and on about the headaches I get from trying to find UP TO DATE documentation from Microsoft about their very own technologies. But maybe I'm just a little slow, so can any of you great people help direct me to SOMETHING that details what I'm looking for?
I’ve done something similar where I use the user’s OneDrive to backup and store data (my data is stored in files as serialised objects.) I would definitely recommend getting the OneDrive SDK from Nuget – it makes life easier as you don’t have to make your own REST calls. From the SDK you can then do:
var oneDriveClient = OneDriveClientExtensions.GetUniversalClient(new[] { "wl.signin", "onedrive.readwrite" })
await oneDriveClient.AuthenticateAsync();
This uses Window’s single sign on to authenticate with OneDrive – i.e. the user isn’t prompted for a username and password, it just authenticates using the Microsoft Account the user is logged into Windows as. The first time your app does this, the user will be prompted to confirm that they are happy for your app to access their OneDrive. If they confirm, they won’t see the popup again and your app will immediately authenticate.
If you want to prompt the user for a username and password – perhaps so they can use a different account if they wish – then I believe you do the same as above, but use OneDriveClientExtentions.GetClientUsingWebAuthenticationBroker() instead. I’ve never tried this, but I think it displays the logon box you are referring to.
To use the OneDrive SDK you need to register your app with OneDrive at dev.onedrive.com, and you need to associate your app with the Windows Store.
I’d recommend working your way through the Getting Started documentation found at github.com/OneDrive/onedrive-sdk-csharp – that’s how I got my code up and running.