Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

Garnik G.'s avatar
Garnik G.
Explorer | Level 4
11 years ago

How to get files by DropBoxRest API in C#

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

  • Garnik G.'s avatar
    Garnik G.
    Explorer | Level 4
    11 years ago

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

  • 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.'s avatar
    Garnik G.
    Explorer | Level 4
    11 years ago

    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

  • 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.'s avatar
    Garnik G.
    Explorer | Level 4
    11 years ago

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

  • 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.'s avatar
    Garnik G.
    Explorer | Level 4
    11 years ago

    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.'s avatar
    Velmurugan N.
    New member | Level 1
    10 years ago

    hi All

    I.m getting the following error

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

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!