1

I am working on a proof of concept for reading files from Dropbox. This is a console app in C#.

All of the 3rd-party tools and examples that I find have this terrible bit of code where the app launches a browser and requires the user to authorize access to Dropbox.

Examples:

All of these examples seem to miss the point.

The problem is - I have already authorized Dropbox access from my app, and I never want to have to do that again!

I have tokens and secrets, but is there any way that I can re-use the ones I already got? I want to be able to run this demo and get a list of files - just that. No extra login.

Daniel Williams
  • 8,912
  • 15
  • 68
  • 107
  • Tokens expire, so no you cant reuse them past the expiry. Even Pins to get the token are usually one-use things. Logging in to get permission is part of the core OAuth model. – Ňɏssa Pøngjǣrdenlarp Jan 04 '15 at 20:39

2 Answers2

1

Use an access token, which you can generate on your dropbox application's page in the "Generated access token" section. https://www.dropbox.com/developers/apps

It seems the token does not expire: Dropbox Access Token Expiry

Using the Dropbox.Net library you can just use the token when creating a new client.

using (var dbx = new DropboxClient("YOUR ACCESS TOKEN"))

More info: https://www.dropbox.com/developers/documentation/dotnet#install

Community
  • 1
  • 1
user1713059
  • 1,425
  • 2
  • 17
  • 34
0

Hmm, it looks like I can take Christophe Greer's example and turn off the call to open a web browser. Then I add a header of this form:

    request.Headers.Add("Authorization:Bearer <the very long token>");

I get this token from Dropbox itself by getting a Generated access token from the application settings page here.

This lets me continue on evaluating the API!

Daniel Williams
  • 8,912
  • 15
  • 68
  • 107
  • That's correct, the Dropbox API supports OAuth 1 and OAuth 2, and you can and should store and re-use the user's access token for future API calls for that user. The access tokens don't expire by themselves, but they can be revoked by the user, e.g., via https://www.dropbox.com/account/security . – Greg Jan 05 '15 at 18:31