I am developing for WP8.1 and probably will port on other platforms.
I want to integrate a OneDrive functionality, however, I can't understand what is the difference between LiveSDK
(from NuGet packages) and OneDrive
API.
It seems that Microsoft
does not communicate at all regarding that, I really don't understand why. As far as I understood, the LiveSDK
is the old one and will be replaced by OneDrive API
, but the LiveSDK
seems so much simpler to use that I can't understand their logic... On top of that both have been updated recently (in April for the LiveSDK
).
OneDrive API
, or keep on the LiveSDK
? Based on a future-proof sight, I will go for the OneDrive API
, but my main concern is:
Is is possible to login as easily on OneDrive API
than with the Live SDK
? (Working temporary solution below)
For now, I have been able to login with the LiveSDK
using a single button and three lines of code, no user input required at all, where the AuthenticateAndContinue
method used by the OneDrive API
opens a Webcontrol and requires to enter manually the login and password.
At the end I have used the LiveSDK
Authentication and use the access token provided with the OneDrive API
. It is not a clean approach from my point of view, but I couldn't manage to get the AuthenticateAndContinue
method to work (I get a 404 error answer after the login).
If anybody has a better solution, I am opened to suggestions :)
The OneDrive REST API is a portion of the Microsoft Graph API which allows your app to connect to content stored in OneDrive and SharePoint.
[Solution extracted from question to get out of "unanswered" stack]
In summary, my current method is the following:
The simplified code is the following:
The method below allows to log in silently, only the first time requires a manual validation from the user allowing the program to use its Live
account.
It does not require any password from the user
var authClient = new LiveAuthClient();
var authResult = await authClient.LoginAsync(new string[] {
"wl.signin", "onedrive.readwrite", "onedrive.appfolder"});
if (authResult.Session == null)
throw new InvalidOperationException("You need to sign in and give consent to the app.");
var Connection = new ODConnection("https://api.onedrive.com/v1.0",
new MicrosoftAccountAuthenticationInfo() { TokenType = "Bearer",
AccessToken = odArgs.Session.AccessToken });
It is not as clean as I would like (using 2 different SDK), but it works :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With