Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropbox api "USER TOKEN", "USER SECRET"

I am trying manipulate files using Dropbox Api by using DropNet Client (C# version of Dropbox CLient 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"

THanks

like image 780
icn Avatar asked Dec 08 '11 00:12

icn


People also ask

What is access token Dropbox?

User Authentication This is the most common authentication type. This type uses an access token for a specific user and app pair, in order to operate on that user's account, to the extent allowed by that app's permission. Applications that authorize only scopes for the User API will receive a user access token.

Where is Dropbox token?

Go to the Dropbox App Console and log in (you need a Dropbox account to do this). Select Create App. After the app is created, you will be taken to the App's settings page for the app. Scroll to the OAuth 2 section, find the Generated access token section and click on Generate.


1 Answers

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). 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

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.

This link lays out the sequence pretty clearly:

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.

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:

// 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. That object contains:

    public string Token { get; set; }
    public string Secret { get; set; }
like image 66
bryanmac Avatar answered Nov 15 '22 00:11

bryanmac