简体   繁体   English

重定向后MVC上的Dropnet

[英]Dropnet on MVC after redirect

I have an MVC website in which I am using the DropNet Api . 我有一个MVC网站,正在其中使用DropNet Api

public ActionResult AuthorizeDropBox()
{
    try
    {
        var _client = new DropNetClient("API KEY", "API SECRET");
        if (_client == null)
            throw new DropboxException();

        var userLogin = _client.GetToken();
        var url = _client.BuildAuthorizeUrl(userLogin, Url.Action("DropBoxCallBack", "Account", null, Request.Url.Scheme));
        return Redirect(url);                
    }

    catch (DropboxException dbe)
    {

    }
}

public ActionResult DropBoxCallBack()
{
    //Not sure here how to access the Dropbox api
    //var fileBytes = _client.GetFile("/Getting Started.pdf");
    return View();
}

So I redirect the user to the Dropbox page that asks the user about allowing my website connect his data and then I DropBoxCallBack is raised. 因此,我将用户重定向到Dropbox页面,该页面询问用户有关允许我的网站连接其数据的信息,然后引发DropBoxCallBack

However I don't have the _client here. 但是我这里没有_client But I even tried putting the _client on Session but I still get errors when trying to access Dropbox functionality. 但是我什至尝试将_client放在Session但是在尝试访问Dropbox功能时仍然出现错误。

Any help would be appreciated. 任何帮助,将不胜感激。

Thanks 谢谢

You were on the right track trying to put the DropNetClient instance in the session. 您在尝试将DropNetClient实例放入会话中的路线正确。 Though you only need to store the userLogin object once you call _client.GetToken() then user that user token and secret to create a new instance of the DropNetClient and finish the authentication process. 尽管您只需要在调用_client.GetToken()之后存储userLogin对象,然后使用该用户令牌和密钥用户来创建DropNetClient的新实例并完成身份验证过程。

For more info have a look at this answer: https://stackoverflow.com/a/25798991/75946 有关更多信息,请参见以下答案: https : //stackoverflow.com/a/25798991/75946

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

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