Daniel Williams
Daniel Williams

Reputation: 9304

Dropbox API - how to connect without logging into Dropbox every time?

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.

Upvotes: 1

Views: 1046

Answers (2)

user1713059
user1713059

Reputation: 1507

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

Upvotes: 1

Daniel Williams
Daniel Williams

Reputation: 9304

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!

Upvotes: 0

Related Questions