user3424349
user3424349

Reputation: 11

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.

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

Thank you

Upvotes: 0

Views: 441

Answers (1)

dkarzon
dkarzon

Reputation: 8038

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. Then you want to call GetAccessToken.

There's a sample Windows Phone project in the Github repo that shows how to do this. https://github.com/dkarzon/DropNet/blob/master/DropNet.Samples/DropNet.Samples.WP7/MainPage.xaml.cs#L63

Upvotes: 3

Related Questions