Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
JayPatel1992
8 years agoHelpful | Level 5
await DropboxOAuth2Helper.ProcessCodeFlowAsync() doesn't completed and breaks between the loop.
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.
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);
4 Replies
- Greg-DB8 years ago
Dropbox Community Moderator
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);
- JayPatel19928 years agoHelpful | Level 5
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-DB8 years ago
Dropbox Community Moderator
That's more of a general C#/async programming design question, so I'm afraid I can't offer insight on that. - JayPatel19928 years agoHelpful | Level 5
No problem. I tried that and now it is working good.
Thank you so much for help.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!