0

我正在 Windows Phone Emulator 上编写一个 Windows 应用程序来与 DropBox 帐户通信,并且正在使用 NuGet 库中的 DropNet 包。

我指的页面是:http ://dkdevelopment.net/what-im-doing/dropnet/

以下是我已完成的步骤:

步骤 1) 创建客户端

DropNetClient GlobalClient = new DropNetClient("TOKEN", "SECRET", "testUserName", "testPassword");

我不确定 userToken 和 userSecret 中的内容,它不能是硬编码的用户名和密码!

步骤 2) 请求令牌

GlobalClient.GetTokenAsync((userToken) =>
        {
            //Dont really need to do anything with userLogin,
            //DropNet takes care of it for now
        },
        (error) =>
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                MessageBox.Show(error.Message);
            });
        });

步骤 3) 构建授权 URL

var url = GlobalClient.BuildAuthorizeUrl("http://dkdevelopment.net/BoxShotLogin.htm");

步骤 4) 将浏览器重定向到 DropBox 登录页面。在此之后,DropBox 确实允许登录,但它显示此警告:“链接应用程序的请求无效”更重要的是,浏览器不会重定向到http://dkdevelopment.net/BoxShotLogin.htm。这表明出了问题。不确定是什么。

Uri testUri = new Uri(url.ToString());
        WebBrowserTask task = new WebBrowserTask();
        task.Uri = testUri;
        task.Show();

步骤 5)这不起作用。GlobalClient.UserLogin.Token 和 GlobalClient.UserLogin.Secret 未设置。

GlobalClient.GetAccessTokenAsync((accessToken) =>
        {
            //Store this token for "remember me" function
            GlobalClient.UserLogin.Token = accessToken.Token;
            GlobalClient.UserLogin.Secret = accessToken.Secret;
        },
        (error) =>
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(error.Message);
                });
        });

有人知道如何解决这个问题吗?

谢谢!

4

2 回答 2

0

I figured out the problem. In Step 2, request token needs to be stored in order to build correct authorize URL and that request token needs to be passed as the first parameter. However when I try to store in the statement lambda like this, it does not get stored. What's the issue here? I think it's the way I might be using lambdas.

GlobalClient.GetTokenAsync((userToken) => 
{ 
    infoTextBlock.Text = userToken.Token; 
    GlobalClient.UserLogin.Token = userToken.Token; 
}
(error) => 
{ 
});

Thanks!

于 2012-10-13T20:59:24.363 回答
0

问题出在以下代码中:

UserLogin.Token = userToken.Token; 

为令牌分配值并不意味着为请求设置了基础凭据。仅当您调用以下命令时才会这样做:

UserLogin = userToken;

如果你问我,课堂界面的设计很糟糕。调用 UserLogin.Token = Something 和 UserLogin = NewLogin(关于底层业务规则)应该没有区别。

于 2013-12-06T04:36:46.167 回答