Onedrive API vs LiveSDK

僤鯓⒐⒋嵵緔 提交于 2019-12-21 07:06:25

问题


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).

So my question is

  • As long as my app has not been published yet, should I move to OneDrive API, or keep on the LiveSDK?
  • Does anyone has already tried both?
  • What are the limitations and benefits of both?

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 :)


回答1:


[Solution extracted from question to get out of "unanswered" stack]

In summary, my current method is the following:

  1. Authenticate using LiveSDK API
  2. Use the session cookie and the OneDrive API from there

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 :)



来源:https://stackoverflow.com/questions/30549692/onedrive-api-vs-livesdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!