1

I am using the below code which works only on my second attempt. When I use it for the first time, it always get Unauthorized, next call it runs successful.

public ActionResult AuthorizeDropBox(string redirectUrl)
{
        var _client = new DropNetClient("XXXX", "XXXX");
        if (_client == null)
            throw new DropboxException();

        var userLogin = _client.GetToken();
        var url = _client.BuildAuthorizeUrl(Url.Action("DropBoxCallBack", "Home", null, Request.Url.Scheme));

        Session["UserToken"] = userLogin.Token;
        Session["UserSecret"] = userLogin.Secret;

        return Redirect(url);
}

public ActionResult DropBoxCallBack()
{
    var userToken = Session["UserToken"];
    var userSecret = Session["UserSecret"];

    var _client = new DropNetClient("XXXX", "XXXX", userToken.ToString(), userSecret.ToString());
    if (_client == null)
        throw new DropboxException();

    var userLogin = _client.GetAccessToken();

    var file = _client.GetFile("/Getting Started.pdf");

    return RedirectToAction("Index", "Home");
}

Any ideas?

Thank you

Sarath Subramanian
  • 20,027
  • 11
  • 82
  • 86
user2779312
  • 661
  • 2
  • 9
  • 23

0 Answers0