简体   繁体   English

Dropbox api“USER TOKEN”,“USER SECRET”

[英]Dropbox api “USER TOKEN”, “USER SECRET”

I am trying manipulate files using Dropbox Api by using DropNet Client (C# version of Dropbox CLient API). 我正在尝试使用DropNet Client(Dropbox CLient API的C#版本)使用Dropbox Api操作文件。 Here is my code: 这是我的代码:

    var client = new DropNetClient(APP_KEY,APP_SECRET);
    client.Delete("/Public/test.txt");

But it seems I need "USER TOKEN" and "USER SECRET" as well. 但似乎我也需要“用户忘记”和“用户秘密”。 Where should I get these two? 我应该在哪里获得这两个? Updated: I just need to manipulate files in my own folders and my shared folders. 更新:我只需要操作我自己的文件夹和共享文件夹中的文件。 I already have APP_KEY and APP_SECRET from myApp page, where can I get "USER TOKEN" and "USER SECRET" 我已经从myApp页面获得APP_KEY和APP_SECRET,在哪里可以获得“USER TOKEN”和“USER SECRET”

THanks 谢谢

When you create your app on the dropbox web site, they give you an APP_KEY (identifies your app) and an APP_SECRET (like a password). 当您在Dropbox网站上创建应用程序时,他们会为您提供APP_KEY(标识您的应用程序)和APP_SECRET(如密码)。 You're essentially registering your app with drop box in order to integrate with their service. 您实际上是使用投递箱注册您的应用程序,以便与他们的服务集成。

Here's an overview: http://www.dropbox.com/developers/start/core 以下是概述: http//www.dropbox.com/developers/start/core

Click the " my apps " link in that page. 点击该页面中的“ 我的应用 ”链接。 You'll have to create or login with your drop box account. 您必须使用您的投递箱帐户创建或登录。 After that, you can create an app. 之后,您可以创建一个应用程序。 Give it a name and description, select access folder or full contents and click OK. 为其命名和说明,选择访问文件夹或完整内容,然后单击“确定”。 They will give you the key and secret after registering your app. 注册您的应用后,他们会给您密钥和秘密。

EDIT: 编辑:

Concerning the specific C# DropNetClient, you're supposed to replace "APP_KEY" and "APP_SECRET" with your appKey and appSecret strings from that site. 关于特定的C#DropNetClient,您应该将“APP_KEY”和“APP_SECRET”替换为该站点的appKey和appSecret字符串。

This link lays out the sequence pretty clearly: 这个链接很清楚地列出了序列:

https://github.com/dkarzon/DropNet https://github.com/dkarzon/DropNet

_client = new DropNetClient("API KEY", "API SECRET");

for example: 例如:

// replace with given app key and secret from site
_client = new DropNetClient("8oz68cz267t52fz", "mavm58321hrhejy");

Once you have a client object, you need to pop a browser and have the user login to drop box with their user account. 拥有客户端对象后,您需要弹出浏览器并让用户使用其用户帐户登录到删除框。 that's covered in step 2 of that link by getting the url. 通过获取网址,在该链接的第2步中介绍了该内容。

var url = _client.BuildAuthorizeUrl();

Now that the user has logged on, you can get a user access token via synchronous or asynchronous methods. 现在用户已登录,您可以通过同步或异步方法获取用户访问令牌。 the user token enables a "remember me" feature without having the user reauthenticating and especially from your app storing their account/pass which you should never do. 用户令牌启用“记住我”功能,而无需用户重新验证,尤其是您的应用程序存储他们永远不应该执行的帐户/通行证。 It's a token that proves they've authenticated with drop box. 这是一个证明他们已经使用投递箱进行身份验证的令牌。 From step 3 of that link: 从该链接的第3步:

// Sync
var accessToken = _client.GetAccessToken(); //Store this token for "remember me" function

// Async
_client.GetAccessTokenAsync((accessToken) =>
    {
        //Store this token for "remember me" function
    },
    (error) =>
    {
        //Handle error
    });

Note that var accessToken is really a DropNet.Models.UserLogin object. 请注意,var accessToken实际上是DropNet.Models.UserLogin对象。 That object contains: 该对象包含:

    public string Token { get; set; }
    public string Secret { get; set; }

The user token/secret is what you get when a user gives your app access to their Dropbox via the browser-based authorization page, described here: 用户令牌/秘密是用户通过基于浏览器的授权页面让您的应用访问其Dropbox时获得的内容,如下所述:

https://www.dropbox.com/developers/core/authentication https://www.dropbox.com/developers/core/authentication

The Dropbox API is intended to link to each user's Dropbox. Dropbox API旨在链接到每个用户的Dropbox。 It sounds like you want it to link to your (developer-owned) Dropbox, which isn't currently supported. 听起来您希望它链接到您当前不支持的(开发者拥有的)Dropbox。 The only option would be to obtain a token via the auth flow in your deve environment, then somehow embed that token inside your app's code. 唯一的选择是通过您的deve环境中的auth流程获取令牌,然后以某种方式将该令牌嵌入您的应用程序代码中。 Keeping that embedded token secret would be a challenge. 保持嵌入式令牌的秘密将是一个挑战。 Also, that embedded fixed token would be tied to your Dropbox account, and you'd have to be very careful never to unlink the app from your account (via https://www.dropbox.com/account#applications ), which would invalidate the token. 此外,嵌入式固定令牌将与您的Dropbox帐户绑定,您必须非常小心,永远不要将应用程序与您的帐户取消链接(通过https://www.dropbox.com/account#applications )使令牌无效。

There is a new way to get a token for your own account without going through all the OAuth stuff. 有一种新方法可以为您自己的帐户获取令牌,而无需浏览所有OAuth内容。 On the Application settings page you will find a button "Generated access token". 在“应用程序设置”页面上,您将找到“生成的访问令牌”按钮。 This generates a token for your own account. 这会为您自己的帐户生成令牌。

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

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