简体   繁体   English

Dropnet中的未经授权的错误

[英]Unauthorized Error in Dropnet

I'm using asp.net mvc 4 and Dropnet to download a file from my dropbox account. 我正在使用asp.net mvc 4Dropnet从我的保管箱帐户下载文件。 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."}]. HTTP响应为[{“错误”:“用户未正确授权请求令牌。”}]。

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. 我只希望访问我的Dropbox帐户,所以我需要知道如何给自己的USER TOKEN和USER SECRET。 I've searched in google a lot for a solution but couldn't find anything that'll help me. 我在Google上搜索了很多解决方案,但是找不到任何可以帮助我的东西。 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; 此行不应在此_client.UserLogin = login; and after this line var url = _client.BuildAuthorizeUrl(); 在此行之后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(); 您将需要将用户重定向到该URL,以便他们可以登录,然后保管箱站点会将他们重定向回您的站点,即在您调用_client.GetAccessToken(); then you will have access to the users dropbox account. 那么您将有权访问用户的保管箱帐户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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