将 ASP.NET Web 应用程序连接到 Dropbox
我正在开发一个网络应用程序,我想让我的用户能够连接个人 Dropbox 帐户。 我将构建文件和文件夹浏览器,但我希望能够首先访问它们。
我有来自 Dropbox 的 ApiKey 和 ApiSecret 用于我的应用程序。
我尝试使用 C# 框架,但我认为这些框架适用于桌面/winform/控制台/移动应用程序。
我能够获得 request_token 但无法获得 access_token。
有人可以解释一下这个问题吗? (使用 Dropbox API 和 ASP.NET Web 应用程序)。
I'm working on a web application and i want to give my users the ability to connect a personal Dropbox account.
I will build the files and folders browser but i want to be able to access them first.
I have a ApiKey and ApiSecret from Dropbox for my application.
I tried to use the C# frameworks but i think those are for desktop/winform/console/mobile applications.
I was able to get a request_token but i cant get access_token.
Can someone please put some light on this issue? (working with Dropbox API with ASP.NET web application).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Sharpbox 好像已经有一段时间没有更新了。您可能想要结账
它位于 nuget 上,只需在 packagemanager 控制台中使用它:
在此博客上了解更多相关信息:
http://dkdevelopment.net/what-im-doing/dropnet/
It seems that Sharpbox hasn't been updated for a while. You might want to checkout
it is on nuget, just use this in the packagemanager console:
read more about it on this blog:
http://dkdevelopment.net/what-im-doing/dropnet/
我找到了完美的解决方案。
我使用了 SharpBox .NET 库...
我使用了它,我能够读取文件夹、获取文件、读取文件内容以供下载等等!
I found the perfect solution.
I used the SharpBox .NET library...
I played with it and i was able to Read folders, get files, read file content for download and more!
我不知道如何使用 Dropbox,但我的应用程序正在使用 www.DriveHQ.com,工作完美,DriveHQ 为我提供了一个私人网站,这太棒了。
I am not sure how to work with Dropbox, but my application is working with www.DriveHQ.com, work perfectly, DriveHQ provides me a private website, that's amazing.
检查 Spring.NET Social Dropbox:http://www.springframework.net/social-dropbox/
发行版中有一个完整的 ASP.NET 示例。
Check Spring.NET Social Dropbox: http://www.springframework.net/social-dropbox/
There is a full ASP.NET example in the distribution.
下面是一个示例(使用 ASP MVC4 和 SharpBox .NET),展示了一个很好的演示。
首先,它尝试从 App_Data 中的文件加载访问令牌。如果存在,请使用令牌读取 Dropbox 上的应用程序文件夹。
如果不存在,请查看当前会话中是否有请求令牌。如果可用,用户可能已向 Web 应用程序授予访问其保管箱的权限,因此请尝试将请求令牌转换为访问令牌。
如果没有请求令牌,请创建它,将其存储在会话中并将用户重定向到 Dropbox,以便系统提示他授予 Web 应用程序对其文件夹的访问权限。
注意:该代码是一个演示。要将其变成多用户和真实场景,您将需要存储每个用户的访问令牌文件,并且应该将访问令牌缓存在会话缓存中,以防止对访问令牌文件的多余读取。
Here is a sample (using ASP MVC4 and SharpBox .NET) that shows a nice demo.
First it tries to load the access token from a file in App_Data. If it is there, use the token to read the app folder on dropbox.
If it is not there see if there is a request token in the current session. If it is available the user might have granted permission to the web application to access his dropbox so try to turn the request token into an access token.
If there is no request token, create it, store it in the session and redirect the user to dropbox so he will be prompted to give the web application access to his folder.
Note: the code is a demo. To turn it into a multi user and real scenario you will need to store the access token file per user and you should cache the access token in the session cache to prevent superfluous reading of the access token file.