AlexGH
AlexGH

Reputation: 2805

Creating instance of Dropbox.API in ASP.net

I'm migrating a project in MVC into the equivalent in ASP.net Core, I need to get access to some files in Dropbox, I've configure my project in ASP.net Core with Dropbox.Api, because it seems that DropNet is not supported in ASP.net Core(when I try to install it I get the following error message: The dependency DropNet 1.10.23 does not support framework .NETCoreApp,Version=v1.0.) If you know any way that I could use DropNet let me know.

So I've installed Dropbox.Api and I've created my own app and I can get access to it using a Dropbox client object:

 DropboxClient client = new DropboxClient("cU5M-a4exaAAAAAAAAABDVZsKsdfsd2343slOeFEo-HByusdgsgsgsf33FyOXH");

But when I'm trying to connect to the Dropbox MVC account it was used DropNet, and the configuration is different(no generated access token in there):

 _client = new DropNetClient("gwie23zapdfddsswt8", "64545ghdfhjcf", userToken: "wdggff662sd4", userSecret: "234564fthhyqo");

I have some questions about it:

1- No way that I can install in ASP.net Core the DropNet package that was used in previous framework versions?

2-I've been following this tutorial, in there they only talk about the Generated access token they don't talk about userToken and userSecret, in the MVC project it was used DropNet they used those parameters to create a Dropbox client. And in the tutorial that I referenced above they just create that client like this:

DropboxClient client = new DropboxClient("cU5M-a4exaAAAAAAAAABDVZsKsdfsd2343slOeFEo-HByusdgsgsgsf33FyOXH");

Is there anyway that I can create that instance using Dropbox.API using userToken and userSecret? DropboxClient only accept two parameters: the generated access token and an instance of DropboxClientConfig.

3- Once deployed my application in ASP.net Core would be possible for every user to download files using the client that I created behind the scenes:

DropboxClient client = new DropboxClient("cU5M-a4exaAAAAAAAAABDVZsKsdfsd2343slOeFEo-HByusdgsgsgsf33FyOXH");

Upvotes: 0

Views: 855

Answers (1)

Henk Mollema
Henk Mollema

Reputation: 46541

If you look at the NuGet package of Dropbox.Api, you can see that it targets DNXCore 5.0 in the PCL package. Which is compatible with .NET Core. Using an imports statement we can tell NuGet that we are compatible with DNX Core 5.0 and want their packages to restore:

"dependencies": {
  "Dropbox.Api": "3.6.0"
},
"frameworks": {
  "netcoreapp1.0": {
    "dependencies": {
      "Microsoft.NETCore.App": {
        "type": "platform",
        "version": "1.0.0"
      }
    },
    "imports": "dnxcore50"
  }
}

Notice the "imports": "dnxcore50" statement.


If you want to use full .NET, you'll have to change your project.json file to something like:

"dependencies": {
  "Dropbox.Api": "3.6.0"
},
"frameworks": {
  "net46": { }
}

Where net46 can be any .NET framework you want to target.

Upvotes: 3

Related Questions