简体   繁体   English

带有DropNet的Windows Phone

[英]Windows Phone with DropNet

I am writing a Windows App on Windows Phone Emulator to communicate with DropBox account and am using DropNet package from NuGet gallery. 我正在Windows Phone模拟器上编写Windows应用程序以与DropBox帐户进行通信,并且正在使用NuGet画廊中的DropNet程序包。

The page that I am referring is: http://dkdevelopment.net/what-im-doing/dropnet/ 我要指的页面是: http : //dkdevelopment.net/what-im-doing/dropnet/

Here are the steps I have done: 这是我已完成的步骤:

Step 1) Creating the client 步骤1)创建客户端

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

I am not sure what goes in userToken and userSecret, it can't be hard-coded username and password! 我不确定userToken和userSecret中包含什么内容,它不能是硬编码的用户名和密码!

Step 2) Requesting Token 步骤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);
            });
        });

Step 3) Building authorizing URL 步骤3)建立授权网址

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

Step 4) Redirecting browser to DropBox Login Page. 步骤4)将浏览器重定向到DropBox登录页面。 After this, DropBox does allow to login, but it displays this warning: "The request to link the app is invalid" And more importantly, the browser does not get redirected to http://dkdevelopment.net/BoxShotLogin.htm . 此后,DropBox确实允许登录,但显示以下警告:“链接应用程序的请求无效”,更重要的是,浏览器未重定向到http://dkdevelopment.net/BoxShotLogin.htm This indicates something went wrong. 这表明出了点问题。 Not sure what though. 虽然不确定。

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

Step 5) This does not work. 步骤5)这不起作用。 GlobalClient.UserLogin.Token and GlobalClient.UserLogin.Secret does not get set. 未设置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);
                });
        });

Anybody knows how to fix this? 有人知道如何解决这个问题吗?

Thanks! 谢谢!

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. 在步骤2中,需要存储请求令牌以构建正确的授权URL,并且该请求令牌需要作为第一个参数传递。 However when I try to store in the statement lambda like this, it does not get stored. 但是,当我尝试像这样在语句lambda中存储时,不会存储它。 What's the issue here? 这里有什么问题? I think it's the way I might be using lambdas. 我认为这就是我可能使用lambda的方式。

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

Thanks! 谢谢!

The issue is in the following code: 问题在以下代码中:

UserLogin.Token = userToken.Token; 

Assigning a value to token doesn't mean the underlying credentials are set for the request. 为令牌分配值并不意味着已为请求设置了基础凭据。 This is only done when you call the following: 仅当您调用以下命令时,此操作才完成:

UserLogin = userToken;

Poor design in the class interface if you ask me. 如果您问我,班级界面的设计不佳。 There should be no difference between calling UserLogin.Token = Something, and UserLogin = NewLogin (with regards to underlying business rules). 调用UserLogin.Token = Something和UserLogin = NewLogin(关于基础业务规则)之间应该没有区别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM