DropNet DropBox的登录,如何以编程方式做一个控制台应用程序? [英] DropNet DropBox login, how to do it programmatically in a console application?

查看:289
本文介绍了DropNet DropBox的登录,如何以编程方式做一个控制台应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问:

我使用DropBox的CSHARP API从这里开始:
https://github.com/dkarzon/DropNet

I'm using a DropBox csharp API from here:
https://github.com/dkarzon/DropNet

从单元测试,并从这里唯一的工作样本 <一href="https://github.com/dkarzon/DropNet/blob/master/DropNet.Samples/DropNet.Samples.Web/Default.aspx.cs" rel="nofollow">https://github.com/dkarzon/DropNet/blob/master/DropNet.Samples/DropNet.Samples.Web/Default.aspx.cs

From the Unit tests, and the only working sample from here https://github.com/dkarzon/DropNet/blob/master/DropNet.Samples/DropNet.Samples.Web/Default.aspx.cs

我想,它的工作原理是这样的:

I figured that it works like this:

DropNet.DropNetClient client = new DropNet.DropNetClient(strApiKey, strAppSecret);

DropNet.Models.UserLogin login = client.GetToken();
client.UserLogin = login;

var accountInfo = client.AccountInfo();
str = accountInfo.quota_info.quota.ToString();

该probem是,它引发的accountinfo异常。 (System.Net.HttpStatus code.Unauthorized) 之前的一切工作正常,我得到的登录(usertoken&安培; usersecret)。

The probem is, it throws an exception on accountinfo. (System.Net.HttpStatusCode.Unauthorized) Everything before works fine, I get the login (usertoken & usersecret) .

我想我的问题是,这部分的示例应用程序:

I think my problem is this part of the sample application:

var url = _client.BuildAuthorizeUrl(Request.Url.ToString() + "?dropboxcallback=1");
Response.Redirect(url);

凡重定向到的Dropbox登录... 我没有一个Web应用程序,所以我没有网址...

Where it redirects to dropbox for a login... I don't have a web application, so I have no URL...

我有一个控制台应用程序,这应该每天晚上自动让我的数据库的备份作为服务,为此,那肯定是非常糟糕的,需要一个网页浏览器,并已在键入电子邮件/用户名+密码的用户。

What I have is a console application, that should make a backup of my database every evening automatically as a service, for which it certainly is very bad requiring a webbrowser and a user which has to type in email/username + password.

我如何做一个登录通过直接提供硬codeD的用户名和密码?

How can I do a login by directly supplying the hardcoded username and password ?

如果我用示例应用程序,那么它的工作原理,但需要输入在网络上的用户名和密码,然后,吸大的时间为一个控制台应用程序...

If I use the sample application, then it works, but that requires typing in the username and password on the web, and that sucks big time for a console application...

推荐答案

这是可能的,使用SharpBox - 测试,工程
人们需要取得AccessToken作为一次性动作手动,则在这之后,可以省略登录页并使用所保存的AccessToken

It is possible, using SharpBox - tested, works.
One needs to acquire the AccessToken as a one-time-action manually, then after that, one can omit the login page and use the saved AccessToken.

http://www.jayway.com / 2012/02/06 /拆箱,保管箱和 - sharpbox-2 /

魔法行是:

Globals.DropBox.Token = AppLimit.CloudComputing.SharpBox.StorageProvider.DropBox.DropBoxStorageProviderTools
.ExchangeDropBoxRequestTokenIntoAccessToken(
      Globals.DropBox.config
    , Globals.DropBox.AppKey, Globals.DropBox.AppSec
    , Globals.DropBox.requestToken
);

这篇关于DropNet DropBox的登录,如何以编程方式做一个控制台应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆