0
votes

I want to implement OneDrive backup for UWP store application - without asking user to enter Login/Password (user already loggedin MS account). Can you point to actual(modern) tutorial how to read and write files to "onedrive.appfolder" only.

I tried multiples examples about accessing OneDrive, all of them outdated and not working: LiveSDK OneDriveSDK(V1,V2) Graph - From Azure Registration portal - two sample applications settled up for registered app - not working with windows auth. Community.Toolkit.OneDriveService (in latest builds service removed with comment -> removing old service and outdated graph implementation). I did not found modern alternative.

I got two main problems: Authorization, most examples made for corporate SharePoint access, all examples failed to use windows auth (without login promt) with error: Can not get user information: check app have right compatibility… It is not true - I can get loggedin user info by System.User , also on first run UWP asking to get Read Account permit. I believe I have done this part using WebAccountProvider with single OneDrive app folder permition question (Scope "onedrive.appfolder") and returned Token. Interesting, but I don't need to create Azure/ App registration to get access to OneDrive App - Store association is enough. But Token doesn't wont to work with Graph or OneDriveSDK V2. https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/WebAccountManagement

Second problem - using OneDrive to read and write folders/files - there is no clear documentation or examples.

Thanks, Maksim

2

2 Answers

1
votes

First, you must auth you app to use OneDrive permission, which means your app will popup a login window, user input email and password, then your app can use OneDrive read & write permission. Then you can storage the token, and next time you can use this token to login without asking user again.

Second, WCT teams released an app named Windows Community Toolkit Sample App, you can download from this url.

Then in Services tab, their is OneDrive Service, refer to this doc.

0
votes

I found the next solution to get simple access to OneDrive Api to save app backup.

To get authentication token I have used WebAccountProvider from WebAccountManagment sample.

To communicate with OneDrive Api I have used Annotate Audio App Sample, also includes authentication and working with https://api.onedrive.com/v1.0/ Api.

Api Documentation https://docs.microsoft.com/en-us/onedrive/developer/rest-api/concepts/special-folders-appfolder?view=odsp-graph-online