Onedrive API与LiveSDK [英] Onedrive API vs LiveSDK
问题描述
我正在为WP8.1开发,可能会移植到其他平台上.
我想集成OneDrive功能,但是,我不明白LiveSDK
(来自NuGet软件包)和OneDrive
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.
看来Microsoft
对此完全没有沟通,我真的不明白为什么.据我了解,LiveSDK
是旧的,并且将由OneDrive API
代替,但是LiveSDK
似乎使用起来非常简单,以至于我无法理解它们的逻辑...最重要的是已最近更新(LiveSDK
于4月).
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
,还是继续使用LiveSDK
? - 是否有人已经 都尝试过吗?
- 两者的局限性和好处是什么?
- As long as my app has not been published yet, should I move to
OneDrive API
, or keep on theLiveSDK
? - Does anyone has already tried both?
- What are the limitations and benefits of both?
基于对未来的展望,我会选择OneDrive API
,但我主要关心的是:
Based on a future-proof sight, I will go for the OneDrive API
, but my main concern is:
与Live SDK
相比,是否可以在OneDrive API
上轻松登录? (下面的工作临时解决方案)
Is is possible to login as easily on OneDrive API
than with the Live SDK
? (Working temporary solution below)
现在,我已经能够使用一个按钮和三行代码使用LiveSDK
登录,根本不需要用户输入,其中OneDrive API
使用的AuthenticateAndContinue
方法打开一个Webcontrol并需要手动输入登录名和密码.
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.
最后,我使用了LiveSDK
身份验证,并使用了OneDrive API
随附的访问令牌.从我的角度来看,这不是一种干净的方法,但是我无法设法使AuthenticateAndContinue
方法正常工作(登录后出现404错误答案).
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 :)
推荐答案
[从问题中提取的解决方案,以摆脱未答复"的堆栈]
[Solution extracted from question to get out of "unanswered" stack]
总而言之,我当前的方法如下:
In summary, my current method is the following:
- 使用LiveSDK API进行身份验证
- 从那里使用会话cookie和OneDrive API
简化代码如下:
下面的方法允许静默登录,仅在第一次时需要用户手动验证,以允许程序使用其Live
帐户.
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.
它不需要用户输入任何密码
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 });
它不像我想要的那样干净(使用2个不同的SDK),但是它可以工作:)
It is not as clean as I would like (using 2 different SDK), but it works :)
这篇关于Onedrive API与LiveSDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!