简体   繁体   中英

Unauthorized Error in Dropnet

I'm using asp.net mvc 4 and Dropnet to download a file from my dropbox account. I'm not sure what is wrong with my code but I get a error whenever I run my project,

Received Response [Unauthorized] : Expected to see [OK]. The HTTP response was [{"error": "Request token has not been properly authorized by a user."}].

Here are my codes,

public ActionResult DropDls()
{
    var _client = new DropNetClient("API KEY", "API SECRET");
    DropNet.Models.UserLogin login = _client.GetToken();
    _client.UserLogin = login;
    var url = _client.BuildAuthorizeUrl();
    var accessToken = _client.GetAccessToken();
    var fileBytes = _client.GetFile("/Getting Started.pdf");

    return View();
}

I want only my Dropbox account to be accessed so I need to know how can I give my own USER TOKEN and USER SECRET. I've searched in google a lot for a solution but couldn't find anything that'll help me. I'm desperate for this one and need help badly from experts. Thanks.

The problem is you are not getting the user to login before trying to access their dropbox account.

This line should not be there _client.UserLogin = login; and after this line var url = _client.BuildAuthorizeUrl(); you will need to redirect the user to that url so they can login, then the dropbox site will redirect them back to your site which is when you make the call _client.GetAccessToken(); then you will have access to the users dropbox account.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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