cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

await DropboxOAuth2Helper.ProcessCodeFlowAsync() doesn't completed and breaks between the loop.

await DropboxOAuth2Helper.ProcessCodeFlowAsync() doesn't completed and breaks between the loop.

JayPatel1992
Helpful | Level 5
Go to solution

I want to get access token using OAuth2Response response = await DropboxOAuth2Helper.ProcessCodeFlowAsync(code, AppKey, AppSecret, uriBuilder.Uri.AbsoluteUri); in C#.Net (not MVC)
Created a method:

public async Task ProcessDropboxCallback(string code)
        {
            var AppKey = "";
            var AppSecret = "";
            var uriBuilder = new UriBuilder(Request.Url);
            uriBuilder.Query = Request.QueryString.ToString();
            uriBuilder.Fragment = null;
            uriBuilder.Query = null;
            OAuth2Response response = await DropboxOAuth2Helper.ProcessCodeFlowAsync(code, AppKey, AppSecret, uriBuilder.Uri.AbsoluteUri);
            string DropboxToken = response.AccessToken;
            Session["DropboxAccessToken"] = DropboxToken;
        }

 and calling above method in page_load as:

ProcessDropboxCallback(code);

 

What is happening here is when the compiler reaches to await method, the loop breaks.

It doesn't goes to string Dropbox, so not able to set the token in session. Also it doesn't continues to page_load, loop breaks and the page loads without continuing code after ProcessDropboxCallback(code). 

Stuck in this, need help.

Thanks.

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

It sounds like the issue is that this is an async method, but you're not waiting for the result. I.e., you probably want to await your method call like this:

await ProcessDropboxCallback(code);

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

It sounds like the issue is that this is an async method, but you're not waiting for the result. I.e., you probably want to await your method call like this:

await ProcessDropboxCallback(code);

JayPatel1992
Helpful | Level 5
Go to solution

Yes, that's true.

But for that I need to make Page_load method "async". Is that a good thing ? Because I am not aware with what will happen if I add async to Page_Load.

Greg-DB
Dropbox Staff
Go to solution
That's more of a general C#/async programming design question, so I'm afraid I can't offer insight on that.

JayPatel1992
Helpful | Level 5
Go to solution

No problem. I tried that and now it is working good.

 

Thank you so much for help.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    JayPatel1992 Helpful | Level 5
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?