简体   繁体   English

使用DropNet API时发生异常

[英]Exception when using DropNet API

i did a lot of research but couldn't find a solution to my problem.I'm building a dropbox client using dropNet API but when i got an exception when trying to get access token. 我做了很多研究,但找不到解决问题的方法。我正在使用dropNet API构建Dropbox客户端,但是当尝试获取访问令牌时遇到异常。

Here is my code: 这是我的代码:

        var client = new DropNetClient("KEY", "SECRET");
        client.GetToken();
        var url = client.BuildAuthorizeUrl();
        Uri targetUri = new Uri(url);
        webBrowser.Navigate(targetUri);

        //the exception raise here because i call the getAccessToken too early
        var accessToken = client.GetAccessToken();

I know i have to redirect user to a web browser so i he can authorize the app, then i should call getAccessToken(), the problem is i don't know how to do that if anyone can help me... 我知道我必须将用户重定向到Web浏览器,以便他可以授权该应用程序,然后我应该调用getAccessToken(),问题是如果有人可以帮助我,我不知道该怎么做...

Thank you 谢谢

The easiest way is to give the BuildUrl function a callback URL then listen for the browser controls navigation events until it gets to that URL. 最简单的方法是为BuildUrl函数提供一个回调URL,然后侦听浏览器控件的导航事件,直到到达该URL。 Then you want to call GetAccessToken. 然后,您要调用GetAccessToken。

There's a sample Windows Phone project in the Github repo that shows how to do this. Github存储库中有一个示例Windows Phone项目,展示了如何执行此操作。 https://github.com/dkarzon/DropNet/blob/master/DropNet.Samples/DropNet.Samples.WP7/MainPage.xaml.cs#L63 https://github.com/dkarzon/DropNet/blob/master/DropNet.Samples/DropNet.Samples.WP7/MainPage.xaml.cs#L63

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

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