cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get files by DropBoxRest API in C#

How to get files by DropBoxRest API in C#

Garnik G.
Explorer | Level 4

Hi

My goal is to get files by DropBoxRest API in C#
Here is my code

var options = new Options
    {
        ClientId = "", //App key
        ClientSecret = "", //App secret
        RedirectUri = "https://www.dropbox.com/1/oauth2/authorize"
    };

// Initialize a new Client (without an AccessToken)
var client = new Client(options);

// Get the OAuth Request Url
var authRequestUrl = await client.Core.OAuth2.AuthorizeAsync(access_token which generated in my account);

// TODO: Navigate to authRequestUrl using the browser, and retrieve the Authorization Code from the response
var authCode = ""; Which code have to be here ???

// Exchange the Authorization Code with Access/Refresh tokens
var token = await client.Core.OAuth2.TokenAsync(authCode); in this line occured the following error
  //An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll      

// Get account info
var accountInfo = await client.Core.Accounts.AccountInfoAsync();

Please give me an advice

19 Replies 19

Steve M.
Dropbox Staff

You could do this, but I would advise against it. Dropbox isn't designed for this kind of account sharing, and anyone who had access to your app would be able to extract the access token and take control of the account (e.g. delete all the files).

Garnik G.
Explorer | Level 4

I totally agree with you. But others users can't have an access to our access_token because they have to use only exe.

Steve M.
Dropbox Staff

If the access token is in the exe file, it can definitely be extracted. (As a potentially easier alternative, a user could just set up an HTTP proxy and look at the Authorization header.)

Garnik G.
Explorer | Level 4

Thank you for the answer.
Can you please explain this

As a potentially easier alternative, a user could just set up an HTTP proxy and look at the Authorization header

Steve M.
Dropbox Staff

I mean that if a user wants to get the access token, they can just run an HTTP proxy (like Fiddler2) and see the Authorization header your app is sending to Dropbox. The access token will be plainly visible there.

My general point is that if you put the access token in the app, users can get it.

Garnik G.
Explorer | Level 4

Thanks. Ok. So what you advice ? how we can use dropbox in this case?

Steve M.
Dropbox Staff

My advice would be to not use Dropbox. The Dropbox API is primarily meant to be used in apps where each user will access his or her own account.

Garnik G.
Explorer | Level 4

Thanks. But I have no choice to create new API and I have no other server. So I don't know what can I do except of DropBox

Velmurugan N.
New member | Level 1

hi All

I.m getting the following error

Dropbox Rest API.Services.Core.OAuth2 does not contain definition for AuthorizeAsync

Steve M.
Dropbox Staff

Velmurugan, please post a new question instead of replying to an old thread.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Steve M. Dropbox Staff
  • User avatar
    Velmurugan N. New member | Level 1
  • User avatar
    Garnik G. Explorer | Level 4
What do Dropbox user levels mean?